From 29eb7200711c771182e14ea770a5f074f44d8093 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 16:22:59 +0100 Subject: [PATCH 01/26] introducing relative includes --- unittest/internal/osal/IntTestMutex.cpp | 2 +- unittest/internal/osal/IntTestSemaphore.cpp | 2 +- unittest/internal/serialize/IntTestSerialization.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/unittest/internal/osal/IntTestMutex.cpp b/unittest/internal/osal/IntTestMutex.cpp index 3fd668df..2899535a 100644 --- a/unittest/internal/osal/IntTestMutex.cpp +++ b/unittest/internal/osal/IntTestMutex.cpp @@ -1,7 +1,7 @@ #include "IntTestMutex.h" #include -#include +#include "../UnittDefinitions.h" #if defined(hosted) #include diff --git a/unittest/internal/osal/IntTestSemaphore.cpp b/unittest/internal/osal/IntTestSemaphore.cpp index 534a6a6d..130fc8ae 100644 --- a/unittest/internal/osal/IntTestSemaphore.cpp +++ b/unittest/internal/osal/IntTestSemaphore.cpp @@ -1,6 +1,6 @@ #include "IntTestSemaphore.h" #include -#include +#include "../UnittDefinitions.h" #include #include diff --git a/unittest/internal/serialize/IntTestSerialization.cpp b/unittest/internal/serialize/IntTestSerialization.cpp index 3f231a41..031fd6fe 100644 --- a/unittest/internal/serialize/IntTestSerialization.cpp +++ b/unittest/internal/serialize/IntTestSerialization.cpp @@ -1,7 +1,7 @@ #include "IntTestSerialization.h" #include #include -#include +#include "../UnittDefinitions.h" #include #include From 8cddf8f509c62ebc0481fba1487efc658e0c95ee Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 16:24:38 +0100 Subject: [PATCH 02/26] more relative includes --- unittest/internal/InternalUnitTester.h | 2 +- unittest/internal/serialize/IntTestSerialization.cpp | 7 ++++--- unittest/internal/serialize/IntTestSerialization.h | 9 +++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/unittest/internal/InternalUnitTester.h b/unittest/internal/InternalUnitTester.h index b301b923..d0b1c106 100644 --- a/unittest/internal/InternalUnitTester.h +++ b/unittest/internal/InternalUnitTester.h @@ -2,7 +2,7 @@ #define FRAMEWORK_TEST_UNITTESTCLASS_H_ #include "UnittDefinitions.h" -#include +#include "../../returnvalues/HasReturnvaluesIF.h" /** * @brief Can be used for internal testing, for example for hardware specific diff --git a/unittest/internal/serialize/IntTestSerialization.cpp b/unittest/internal/serialize/IntTestSerialization.cpp index 031fd6fe..1e33ff33 100644 --- a/unittest/internal/serialize/IntTestSerialization.cpp +++ b/unittest/internal/serialize/IntTestSerialization.cpp @@ -1,8 +1,9 @@ #include "IntTestSerialization.h" -#include -#include #include "../UnittDefinitions.h" -#include +#include "../../serialize/SerializeElement.h" +#include "../../serialize/SerialBufferAdapter.h" +#include "../../serialize/SerializeIF.h" + #include using retval = HasReturnvaluesIF; diff --git a/unittest/internal/serialize/IntTestSerialization.h b/unittest/internal/serialize/IntTestSerialization.h index f8841b82..e8dbd35a 100644 --- a/unittest/internal/serialize/IntTestSerialization.h +++ b/unittest/internal/serialize/IntTestSerialization.h @@ -1,6 +1,7 @@ -#ifndef UNITTEST_INTERNAL_INTTESTSERIALIZATION_H_ -#define UNITTEST_INTERNAL_INTTESTSERIALIZATION_H_ -#include +#ifndef FSFW_UNITTEST_INTERNAL_INTTESTSERIALIZATION_H_ +#define FSFW_UNITTEST_INTERNAL_INTTESTSERIALIZATION_H_ + +#include "../../returnvalues/HasReturnvaluesIF.h" #include namespace testserialize { @@ -12,4 +13,4 @@ ReturnValue_t test_serial_buffer_adapter(); extern std::array test_array; } -#endif /* UNITTEST_INTERNAL_INTTESTSERIALIZATION_H_ */ +#endif /* FSFW_UNITTEST_INTERNAL_INTTESTSERIALIZATION_H_ */ From c741ef3945b1536f45a7cac4fd08c5029c536083 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 16:50:02 +0100 Subject: [PATCH 03/26] using relative includes now --- unittest/internal/UnittDefinitions.cpp | 2 +- unittest/internal/osal/IntTestMq.cpp | 9 +++++---- unittest/internal/osal/IntTestMutex.cpp | 6 +++--- unittest/internal/osal/IntTestSemaphore.cpp | 7 ++++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/unittest/internal/UnittDefinitions.cpp b/unittest/internal/UnittDefinitions.cpp index 0bdbfcc7..6265e9fd 100644 --- a/unittest/internal/UnittDefinitions.cpp +++ b/unittest/internal/UnittDefinitions.cpp @@ -1,4 +1,4 @@ -#include +#include "UnittDefinitions.h" ReturnValue_t unitt::put_error(std::string errorId) { sif::error << "Unit Tester error: Failed at test ID " diff --git a/unittest/internal/osal/IntTestMq.cpp b/unittest/internal/osal/IntTestMq.cpp index 63016374..8d95f51e 100644 --- a/unittest/internal/osal/IntTestMq.cpp +++ b/unittest/internal/osal/IntTestMq.cpp @@ -1,7 +1,8 @@ -#include -#include -#include -#include +#include "IntTestMq.h" +#include "../UnittDefinitions.h" + +#include "../../ipc/MessageQueueIF.h" +#include "../../ipc/QueueFactory.h" #include diff --git a/unittest/internal/osal/IntTestMutex.cpp b/unittest/internal/osal/IntTestMutex.cpp index 2899535a..01581347 100644 --- a/unittest/internal/osal/IntTestMutex.cpp +++ b/unittest/internal/osal/IntTestMutex.cpp @@ -1,10 +1,10 @@ #include "IntTestMutex.h" -#include +#include "../../ipc/MutexFactory.h" #include "../UnittDefinitions.h" #if defined(hosted) -#include +#include "../../osal/hosted/Mutex.h" #include #include #endif @@ -20,7 +20,7 @@ void testmutex::testMutex() { // timed_mutex from the C++ library specifies undefined behaviour if // the timed mutex is locked twice from the same thread. #if defined(hosted) - // hold on, this actually worked ? :-D This calls the function from + // This calls the function from // another thread and stores the returnvalue in a future. auto future = std::async(&MutexIF::lockMutex, mutex, 1); result = future.get(); diff --git a/unittest/internal/osal/IntTestSemaphore.cpp b/unittest/internal/osal/IntTestSemaphore.cpp index 130fc8ae..f260b6a5 100644 --- a/unittest/internal/osal/IntTestSemaphore.cpp +++ b/unittest/internal/osal/IntTestSemaphore.cpp @@ -1,8 +1,9 @@ #include "IntTestSemaphore.h" -#include #include "../UnittDefinitions.h" -#include -#include + +#include "../../tasks/SemaphoreFactory.h" +#include "../../serviceinterface/ServiceInterfaceStream.h" +#include "../../timemanager/Stopwatch.h" void testsemaph::testBinSemaph() { From a0689320d1e72cb41a1059a4c1254d3533cb7d8e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 16:55:24 +0100 Subject: [PATCH 04/26] more include fixes --- unittest/tests/container/RingBufferTest.cpp | 4 ++-- unittest/tests/container/TestArrayList.cpp | 5 +++-- unittest/tests/container/TestDynamicFifo.cpp | 6 +++--- unittest/tests/container/TestFifo.cpp | 6 +++--- unittest/tests/container/TestFixedArrayList.cpp | 4 ++-- unittest/tests/container/TestFixedOrderedMultimap.cpp | 4 ++-- unittest/tests/osal/TestMessageQueue.cpp | 8 ++++---- unittest/tests/serialize/TestSerialLinkedPacket.cpp | 7 ++++--- unittest/tests/serialize/TestSerialization.cpp | 2 +- 9 files changed, 24 insertions(+), 22 deletions(-) diff --git a/unittest/tests/container/RingBufferTest.cpp b/unittest/tests/container/RingBufferTest.cpp index 8b82d407..9c1c8a23 100644 --- a/unittest/tests/container/RingBufferTest.cpp +++ b/unittest/tests/container/RingBufferTest.cpp @@ -1,7 +1,7 @@ -#include -#include #include "../../core/CatchDefinitions.h" +#include "../../container/SimpleRingBuffer.h" +#include #include TEST_CASE("Ring Buffer Test" , "[RingBufferTest]") { diff --git a/unittest/tests/container/TestArrayList.cpp b/unittest/tests/container/TestArrayList.cpp index 914188cb..2f884276 100644 --- a/unittest/tests/container/TestArrayList.cpp +++ b/unittest/tests/container/TestArrayList.cpp @@ -1,5 +1,6 @@ -#include -#include +#include "../../container/ArrayList.h" +#include "../../returnvalues/HasReturnvaluesIF.h" + #include #include "../../core/CatchDefinitions.h" diff --git a/unittest/tests/container/TestDynamicFifo.cpp b/unittest/tests/container/TestDynamicFifo.cpp index 6c9b7415..bb19131e 100644 --- a/unittest/tests/container/TestDynamicFifo.cpp +++ b/unittest/tests/container/TestDynamicFifo.cpp @@ -1,7 +1,7 @@ -#include -#include -#include +#include "../../container/DynamicFIFO.h" +#include "../../container/FIFO.h" +#include "../../returnvalues/HasReturnvaluesIF.h" #include #include diff --git a/unittest/tests/container/TestFifo.cpp b/unittest/tests/container/TestFifo.cpp index 3775f424..bd727e00 100644 --- a/unittest/tests/container/TestFifo.cpp +++ b/unittest/tests/container/TestFifo.cpp @@ -1,7 +1,7 @@ -#include -#include -#include +#include "../../container/DynamicFIFO.h" +#include "../../container/FIFO.h" +#include "../../returnvalues/HasReturnvaluesIF.h" #include #include "../../core/CatchDefinitions.h" diff --git a/unittest/tests/container/TestFixedArrayList.cpp b/unittest/tests/container/TestFixedArrayList.cpp index 737932e3..5a1bd280 100644 --- a/unittest/tests/container/TestFixedArrayList.cpp +++ b/unittest/tests/container/TestFixedArrayList.cpp @@ -1,7 +1,7 @@ #include "../../core/CatchDefinitions.h" -#include -#include +#include "../../container/FixedArrayList.h" +#include "../../returnvalues/HasReturnvaluesIF.h" #include diff --git a/unittest/tests/container/TestFixedOrderedMultimap.cpp b/unittest/tests/container/TestFixedOrderedMultimap.cpp index 95194cb5..e625b559 100644 --- a/unittest/tests/container/TestFixedOrderedMultimap.cpp +++ b/unittest/tests/container/TestFixedOrderedMultimap.cpp @@ -1,5 +1,5 @@ -#include -#include +#include "../../container/FixedOrderedMultimap.h" +#include "../../returnvalues/HasReturnvaluesIF.h" #include #include "../../core/CatchDefinitions.h" diff --git a/unittest/tests/osal/TestMessageQueue.cpp b/unittest/tests/osal/TestMessageQueue.cpp index 8e59fa08..441d32e7 100644 --- a/unittest/tests/osal/TestMessageQueue.cpp +++ b/unittest/tests/osal/TestMessageQueue.cpp @@ -1,8 +1,8 @@ -#include -#include -#include "catch.hpp" +#include "../../ipc/MessageQueueIF.h" +#include "../../ipc/QueueFactory.h" +#include #include -#include "core/CatchDefinitions.h" +#include "../../core/CatchDefinitions.h" TEST_CASE("MessageQueue Basic Test","[TestMq]") { MessageQueueIF* testSenderMq = diff --git a/unittest/tests/serialize/TestSerialLinkedPacket.cpp b/unittest/tests/serialize/TestSerialLinkedPacket.cpp index 0a09e430..fbe48894 100644 --- a/unittest/tests/serialize/TestSerialLinkedPacket.cpp +++ b/unittest/tests/serialize/TestSerialLinkedPacket.cpp @@ -1,8 +1,9 @@ -#include +#include "TestSerialLinkedPacket.h" +#include "../../core/CatchDefinitions.h" + +#include "../../globalfunctions/arrayprinter.h" #include -#include "../../core/CatchDefinitions.h" -#include "TestSerialLinkedPacket.h" TEST_CASE("Serial Linked Packet" , "[SerLinkPacket]") { diff --git a/unittest/tests/serialize/TestSerialization.cpp b/unittest/tests/serialize/TestSerialization.cpp index 4c9ba181..6e31170a 100644 --- a/unittest/tests/serialize/TestSerialization.cpp +++ b/unittest/tests/serialize/TestSerialization.cpp @@ -1,4 +1,4 @@ -#include +#include "../../serialize/SerializeAdapter.h" #include "catch.hpp" #include From 5eb2cbde0eb117fff237d531d113f3a79b89f15a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 17:08:03 +0100 Subject: [PATCH 05/26] some additional ionclude fixes --- unittest/tests/container/TestFixedMap.cpp | 4 ++-- unittest/tests/serialize/TestSerialBufferAdapter.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/unittest/tests/container/TestFixedMap.cpp b/unittest/tests/container/TestFixedMap.cpp index 079062f0..da0c84e3 100644 --- a/unittest/tests/container/TestFixedMap.cpp +++ b/unittest/tests/container/TestFixedMap.cpp @@ -1,5 +1,5 @@ -#include -#include +#include "../../container/FixedMap.h" +#include "../../returnvalues/HasReturnvaluesIF.h" #include #include "../../core/CatchDefinitions.h" diff --git a/unittest/tests/serialize/TestSerialBufferAdapter.cpp b/unittest/tests/serialize/TestSerialBufferAdapter.cpp index 9919ed84..07cd3f9c 100644 --- a/unittest/tests/serialize/TestSerialBufferAdapter.cpp +++ b/unittest/tests/serialize/TestSerialBufferAdapter.cpp @@ -1,4 +1,4 @@ -#include +#include "../../serialize/SerialBufferAdapter.h" #include #include "../../core/CatchDefinitions.h" From 29e701d14df9ffe6e4d2c891a26facbc3a4e7af2 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 17:08:46 +0100 Subject: [PATCH 06/26] op divider additional features --- globalfunctions/PeriodicOperationDivider.cpp | 14 ++++++++++++-- globalfunctions/PeriodicOperationDivider.h | 12 +++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/globalfunctions/PeriodicOperationDivider.cpp b/globalfunctions/PeriodicOperationDivider.cpp index ad3b8bbd..28e98feb 100644 --- a/globalfunctions/PeriodicOperationDivider.cpp +++ b/globalfunctions/PeriodicOperationDivider.cpp @@ -7,16 +7,26 @@ PeriodicOperationDivider::PeriodicOperationDivider(uint32_t divider, } bool PeriodicOperationDivider::checkAndIncrement() { - if(counter >= divider) { + bool opNecessary = check(); + if(opNecessary) { if(resetAutomatically) { counter = 0; } - return true; + return opNecessary; } counter ++; + return opNecessary; +} + +bool PeriodicOperationDivider::check() { + if(counter >= divider) { + return true; + } return false; } + + void PeriodicOperationDivider::resetCounter() { counter = 0; } diff --git a/globalfunctions/PeriodicOperationDivider.h b/globalfunctions/PeriodicOperationDivider.h index dd970fb8..7f7fb469 100644 --- a/globalfunctions/PeriodicOperationDivider.h +++ b/globalfunctions/PeriodicOperationDivider.h @@ -21,17 +21,27 @@ public: */ PeriodicOperationDivider(uint32_t divider, bool resetAutomatically = true); + /** * Check whether operation is necessary. * If an operation is necessary and the class has been * configured to be reset automatically, the counter will be reset. - * If not, the counter will be incremented. + * * @return * -@c true if the counter is larger or equal to the divider * -@c false otherwise */ bool checkAndIncrement(); + /** + * Checks whether an operation is necessary. + * This function will not increment the counter! + * @return + * -@c true if the counter is larger or equal to the divider + * -@c false otherwise + */ + bool check(); + /** * Can be used to reset the counter to 0 manually. */ From 606aac687b7d4eec45fa285f16d37958dc7a618a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 17:44:36 +0100 Subject: [PATCH 07/26] make event api change --- events/Event.cpp | 6 ++++-- events/Event.h | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/events/Event.cpp b/events/Event.cpp index ea3d46fe..0f76b438 100644 --- a/events/Event.cpp +++ b/events/Event.cpp @@ -1,4 +1,5 @@ #include "Event.h" + namespace EVENT { EventId_t getEventId(Event event) { return (event & 0xFFFF); @@ -8,7 +9,8 @@ EventSeverity_t getSeverity(Event event) { return ((event >> 16) & 0xFF); } -Event makeEvent(EventId_t eventId, EventSeverity_t eventSeverity) { - return (eventSeverity << 16) + (eventId & 0xFFFF); +Event makeEvent(uint8_t subsystemId, uint8_t uniqueEventId, + EventSeverity_t eventSeverity) { + return (eventSeverity << 16) + (subsystemId * 100) + uniqueEventId; } } diff --git a/events/Event.h b/events/Event.h index aba156f2..90ff1a90 100644 --- a/events/Event.h +++ b/events/Event.h @@ -18,9 +18,10 @@ EventId_t getEventId(Event event); EventSeverity_t getSeverity(Event event); -Event makeEvent(EventId_t eventId, EventSeverity_t eventSeverity); - +Event makeEvent(uint8_t subsystemId, uint8_t uniqueEventId, + EventSeverity_t eventSeverity); } + namespace SEVERITY { static const EventSeverity_t INFO = 1; static const EventSeverity_t LOW = 2; From 94b108e03df766c50dd3178b95264b6a3c663d9c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 1 Dec 2020 17:45:23 +0100 Subject: [PATCH 08/26] changelog update --- CHANGELOG | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index a6686478..c221c811 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,3 +11,7 @@ a C file without issues - It is now possible to change the message queue depth for the telecommand verification service (PUS1) - The same is possible for the event reporting service (PUS5) - PUS Health Service added, which allows to command and retrieve health via PUS packets + +### Events + +- makeEvent function: Not takes three input parameters instead of two and allows setting a unique ID From 37196c8e3b5e2795dc75243aa38412464e79de9e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 1 Dec 2020 23:47:11 +0100 Subject: [PATCH 09/26] atomic fix --- osal/host/FixedTimeslotTask.h | 2 +- osal/host/PeriodicTask.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osal/host/FixedTimeslotTask.h b/osal/host/FixedTimeslotTask.h index 9985e2ee..f3fffd0f 100644 --- a/osal/host/FixedTimeslotTask.h +++ b/osal/host/FixedTimeslotTask.h @@ -74,7 +74,7 @@ protected: //!< Typedef for the List of objects. typedef std::vector ObjectList; std::thread mainThread; - std::atomic terminateThread = false; + std::atomic terminateThread { false }; //! Polling sequence table which contains the object to execute //! and information like the timeslots and the passed execution step. diff --git a/osal/host/PeriodicTask.h b/osal/host/PeriodicTask.h index 7689788a..00cb6a24 100644 --- a/osal/host/PeriodicTask.h +++ b/osal/host/PeriodicTask.h @@ -69,7 +69,7 @@ protected: //!< Typedef for the List of objects. typedef std::vector ObjectList; std::thread mainThread; - std::atomic terminateThread = false; + std::atomic terminateThread { false }; /** * @brief This attribute holds a list of objects to be executed. From a92f6c5d8e06c3cee2328671d1e3138211ba49e4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Dec 2020 00:05:54 +0100 Subject: [PATCH 10/26] mutex bugfix for host --- osal/host/Mutex.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osal/host/Mutex.cpp b/osal/host/Mutex.cpp index 8471cab8..fa3aa24c 100644 --- a/osal/host/Mutex.cpp +++ b/osal/host/Mutex.cpp @@ -4,12 +4,12 @@ Mutex::Mutex() {} ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { - if(timeoutMs == MutexIF::BLOCKING) { + if(timeoutType == MutexIF::BLOCKING) { mutex.lock(); locked = true; return HasReturnvaluesIF::RETURN_OK; } - else if(timeoutMs == MutexIF::POLLING) { + else if(timeoutType == MutexIF::POLLING) { if(mutex.try_lock()) { locked = true; return HasReturnvaluesIF::RETURN_OK; From 206d4b58b287a6a4a56df478d010225bfefe583d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Dec 2020 00:17:12 +0100 Subject: [PATCH 11/26] removed boolean var --- osal/host/Mutex.cpp | 7 ------- osal/host/Mutex.h | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/osal/host/Mutex.cpp b/osal/host/Mutex.cpp index fa3aa24c..ad8873df 100644 --- a/osal/host/Mutex.cpp +++ b/osal/host/Mutex.cpp @@ -6,19 +6,16 @@ Mutex::Mutex() {} ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { if(timeoutType == MutexIF::BLOCKING) { mutex.lock(); - locked = true; return HasReturnvaluesIF::RETURN_OK; } else if(timeoutType == MutexIF::POLLING) { if(mutex.try_lock()) { - locked = true; return HasReturnvaluesIF::RETURN_OK; } } else if(timeoutMs > MutexIF::POLLING){ auto chronoMs = std::chrono::milliseconds(timeoutMs); if(mutex.try_lock_for(chronoMs)) { - locked = true; return HasReturnvaluesIF::RETURN_OK; } } @@ -26,11 +23,7 @@ ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { } ReturnValue_t Mutex::unlockMutex() { - if(not locked) { - return MutexIF::CURR_THREAD_DOES_NOT_OWN_MUTEX; - } mutex.unlock(); - locked = false; return HasReturnvaluesIF::RETURN_OK; } diff --git a/osal/host/Mutex.h b/osal/host/Mutex.h index 24dafbbd..c0fa19b7 100644 --- a/osal/host/Mutex.h +++ b/osal/host/Mutex.h @@ -22,7 +22,7 @@ public: std::timed_mutex* getMutexHandle(); private: - bool locked = false; + //bool locked = false; std::timed_mutex mutex; }; From f5c384de14da3275fbd00487a2bc481de9cd99ea Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Dec 2020 00:27:53 +0100 Subject: [PATCH 12/26] some bugfixes --- osal/windows/TmTcWinUdpBridge.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osal/windows/TmTcWinUdpBridge.cpp b/osal/windows/TmTcWinUdpBridge.cpp index 7e283c2a..1f66290f 100644 --- a/osal/windows/TmTcWinUdpBridge.cpp +++ b/osal/windows/TmTcWinUdpBridge.cpp @@ -6,6 +6,7 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, uint16_t serverPort, uint16_t clientPort): TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { mutex = MutexFactory::instance()->createMutex(); + communicationLinkUp = false; // Initiates Winsock DLL. WSAData wsaData; @@ -90,7 +91,6 @@ ReturnValue_t TmTcWinUdpBridge::sendTm(const uint8_t *data, size_t dataLen) { // sif::debug << "TmTcUnixUdpBridge::sendTm: " << bytesSent << " bytes were" // " sent." << std::endl; return HasReturnvaluesIF::RETURN_OK; - return HasReturnvaluesIF::RETURN_OK; } void TmTcWinUdpBridge::checkAndSetClientAddress(sockaddr_in newAddress) { @@ -101,6 +101,7 @@ void TmTcWinUdpBridge::checkAndSetClientAddress(sockaddr_in newAddress) { // &newAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; // sif::debug << "IP Address Old: " << inet_ntop(AF_INET, // &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; + registerCommConnect(); // Set new IP address if it has changed. if(clientAddress.sin_addr.s_addr != newAddress.sin_addr.s_addr) { @@ -114,7 +115,7 @@ void TmTcWinUdpBridge::handleSocketError() { switch(errCode) { case(WSANOTINITIALISED): { sif::info << "TmTcWinUdpBridge::handleSocketError: WSANOTINITIALISED: " - << "WSAStartup(...) call " << "necessary" << std::endl; + << "WSAStartup(...) call necessary" << std::endl; break; } default: { @@ -154,11 +155,11 @@ void TmTcWinUdpBridge::handleSendError() { switch(errCode) { case(WSANOTINITIALISED): { sif::info << "TmTcWinUdpBridge::handleSendError: WSANOTINITIALISED: " - << "WSAStartup(...) call " << "necessary" << std::endl; + << "WSAStartup(...) call necessary" << std::endl; break; } case(WSAEADDRNOTAVAIL): { - sif::info << "TmTcWinUdpBridge::handleReadError: WSAEADDRNOTAVAIL: " + sif::info << "TmTcWinUdpBridge::handleSendError: WSAEADDRNOTAVAIL: " << "Check target address. " << std::endl; break; } From 73d3defe9f1edc043911e17884ca09d8dcdda48a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Dec 2020 00:32:07 +0100 Subject: [PATCH 13/26] error output improved --- osal/host/QueueMapManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osal/host/QueueMapManager.cpp b/osal/host/QueueMapManager.cpp index 1b2094e9..621f46bc 100644 --- a/osal/host/QueueMapManager.cpp +++ b/osal/host/QueueMapManager.cpp @@ -44,7 +44,7 @@ MessageQueueIF* QueueMapManager::getMessageQueue( return queueIter->second; } else { - sif::warning << "QueueMapManager::getQueueHandle: The ID" << + sif::warning << "QueueMapManager::getQueueHandle: The ID " << messageQueueId << " does not exists in the map" << std::endl; return nullptr; } From 8ad30d489a35cdd6ee27c2e14cfd907d85b62ee0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Dec 2020 00:58:13 +0100 Subject: [PATCH 14/26] important bugfix for host osal --- osal/host/PeriodicTask.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/osal/host/PeriodicTask.cpp b/osal/host/PeriodicTask.cpp index f4ee079b..fb236963 100644 --- a/osal/host/PeriodicTask.cpp +++ b/osal/host/PeriodicTask.cpp @@ -89,6 +89,10 @@ ReturnValue_t PeriodicTask::sleepFor(uint32_t ms) { } void PeriodicTask::taskFunctionality() { + for (const auto& object: objectList) { + object->initializeAfterTaskCreation(); + } + std::chrono::milliseconds periodChrono(static_cast(period*1000)); auto currentStartTime { std::chrono::duration_cast( @@ -101,9 +105,8 @@ void PeriodicTask::taskFunctionality() { if(terminateThread.load()) { break; } - for (ObjectList::iterator it = objectList.begin(); - it != objectList.end(); ++it) { - (*it)->performOperation(); + for (const auto& object: objectList) { + object->performOperation(); } if(not delayForInterval(¤tStartTime, periodChrono)) { sif::warning << "PeriodicTask: " << taskName << From 7b742a2e6775d8f2b5e8b0121d39a84d293cdd94 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Dec 2020 01:00:07 +0100 Subject: [PATCH 15/26] warning removed from osal --- osal/host/PeriodicTask.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osal/host/PeriodicTask.cpp b/osal/host/PeriodicTask.cpp index fb236963..5662c7cc 100644 --- a/osal/host/PeriodicTask.cpp +++ b/osal/host/PeriodicTask.cpp @@ -98,7 +98,7 @@ void PeriodicTask::taskFunctionality() { std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()) }; - auto nextStartTime{ currentStartTime }; + auto nextStartTime { currentStartTime }; /* Enter the loop that defines the task behavior. */ for (;;) { @@ -109,8 +109,6 @@ void PeriodicTask::taskFunctionality() { object->performOperation(); } if(not delayForInterval(¤tStartTime, periodChrono)) { - sif::warning << "PeriodicTask: " << taskName << - " missed deadline!\n" << std::flush; if(deadlineMissedFunc != nullptr) { this->deadlineMissedFunc(); } From 558220643e05a6eaaad0fce5107c3a1c12eea9ae Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Dec 2020 01:01:31 +0100 Subject: [PATCH 16/26] small form improvements --- osal/host/FixedTimeslotTask.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osal/host/FixedTimeslotTask.cpp b/osal/host/FixedTimeslotTask.cpp index e78c974a..7000024e 100644 --- a/osal/host/FixedTimeslotTask.cpp +++ b/osal/host/FixedTimeslotTask.cpp @@ -115,8 +115,9 @@ void FixedTimeslotTask::taskFunctionality() { this->pollingSeqTable.executeAndAdvance(); if (not pollingSeqTable.slotFollowsImmediately()) { // we need to wait before executing the current slot - //this gives us the time to wait: - interval = chron_ms(this->pollingSeqTable.getIntervalToPreviousSlotMs()); + // this gives us the time to wait: + interval = chron_ms( + this->pollingSeqTable.getIntervalToPreviousSlotMs()); delayForInterval(¤tStartTime, interval); //TODO deadline missed check } From 2deb7037b0e58156a8fc04095b57c9eee0003395 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Dec 2020 01:07:40 +0100 Subject: [PATCH 17/26] todo added --- osal/host/FixedTimeslotTask.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osal/host/FixedTimeslotTask.cpp b/osal/host/FixedTimeslotTask.cpp index 7000024e..9e892bb5 100644 --- a/osal/host/FixedTimeslotTask.cpp +++ b/osal/host/FixedTimeslotTask.cpp @@ -46,7 +46,7 @@ FixedTimeslotTask::FixedTimeslotTask(const char *name, TaskPriority setPriority, << GetLastError() << std::endl; } #elif defined(LINUX) - // we can just copy and paste the code from linux here. + // TODO: we can just copy and paste the code from the linux OSAL here. #endif } From 03aacea4ddd5f0ab293dd319ddad2860c99cd6aa Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 3 Dec 2020 14:44:11 +0100 Subject: [PATCH 18/26] fixed unittest --- unittest/core/CatchFactory.cpp | 60 ++++ .../objects/Factory.h => core/CatchFactory.h} | 0 unittest/core/CatchSetup.cpp | 3 +- unittest/testcfg/objects/Factory.cpp | 34 --- unittest/tests/action/TestActionHelper.cpp | 213 +++++++------- unittest/tests/action/TestActionHelper.h | 263 +++++++++--------- 6 files changed, 300 insertions(+), 273 deletions(-) create mode 100644 unittest/core/CatchFactory.cpp rename unittest/{testcfg/objects/Factory.h => core/CatchFactory.h} (100%) delete mode 100644 unittest/testcfg/objects/Factory.cpp diff --git a/unittest/core/CatchFactory.cpp b/unittest/core/CatchFactory.cpp new file mode 100644 index 00000000..cf10e94a --- /dev/null +++ b/unittest/core/CatchFactory.cpp @@ -0,0 +1,60 @@ +#include "CatchFactory.h" + +#include "../../events/EventManager.h" +#include "../../health/HealthTable.h" + +#include "../../internalError/InternalErrorReporter.h" +#include "../../objectmanager/frameworkObjects.h" +#include "../../storagemanager/PoolManager.h" + +/** + * @brief Produces system objects. + * @details + * Build tasks by using SystemObject Interface (Interface). + * Header files of all tasks must be included + * Please note that an object has to implement the system object interface + * if the interface validity is checked or retrieved later by using the + * get(object_id) function from the ObjectManagerIF. + * + * Framework objects are created first. + * + * @ingroup init + */ +void Factory::produce(void) { + setStaticFrameworkObjectIds(); + new EventManager(objects::EVENT_MANAGER); + new HealthTable(objects::HEALTH_TABLE); + //new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); + + { + static constexpr uint8_t NUMBER_OF_POOLS = 5; + const uint16_t element_sizes[NUMBER_OF_POOLS] = {16, 32, 64, 128, 1024}; + const uint16_t n_elements[NUMBER_OF_POOLS] = {100, 50, 25, 15, 5}; + new PoolManager(objects::TC_STORE, element_sizes, + n_elements); + } + + { + static constexpr uint8_t NUMBER_OF_POOLS = 5; + const uint16_t element_sizes[NUMBER_OF_POOLS] = {16, 32, 64, 128, 1024}; + const uint16_t n_elements[NUMBER_OF_POOLS] = {100, 50, 25, 15, 5}; + new PoolManager(objects::TM_STORE, element_sizes, + n_elements); + } + + { + static constexpr uint8_t NUMBER_OF_POOLS = 6; + const uint16_t element_sizes[NUMBER_OF_POOLS] = {32, 64, 512, + 1024, 2048, 4096}; + const uint16_t n_elements[NUMBER_OF_POOLS] = {200, 100, 50, 25, 15, 5}; + new PoolManager(objects::IPC_STORE, element_sizes, + n_elements); + } + +} + +void Factory::setStaticFrameworkObjectIds() { + +} + + diff --git a/unittest/testcfg/objects/Factory.h b/unittest/core/CatchFactory.h similarity index 100% rename from unittest/testcfg/objects/Factory.h rename to unittest/core/CatchFactory.h diff --git a/unittest/core/CatchSetup.cpp b/unittest/core/CatchSetup.cpp index f8543fd2..cb5bd33e 100644 --- a/unittest/core/CatchSetup.cpp +++ b/unittest/core/CatchSetup.cpp @@ -1,8 +1,7 @@ #include "CatchDefinitions.h" +#include "CatchFactory.h" #include -#include - #ifdef GCOV #include diff --git a/unittest/testcfg/objects/Factory.cpp b/unittest/testcfg/objects/Factory.cpp deleted file mode 100644 index e05b7942..00000000 --- a/unittest/testcfg/objects/Factory.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "Factory.h" - -#include -#include - -#include -#include - -/** - * @brief Produces system objects. - * @details - * Build tasks by using SystemObject Interface (Interface). - * Header files of all tasks must be included - * Please note that an object has to implement the system object interface - * if the interface validity is checked or retrieved later by using the - * get(object_id) function from the ObjectManagerIF. - * - * Framework objects are created first. - * - * @ingroup init - */ -void Factory::produce(void) { - setStaticFrameworkObjectIds(); - new EventManager(objects::EVENT_MANAGER); - new HealthTable(objects::HEALTH_TABLE); - new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); - -} - -void Factory::setStaticFrameworkObjectIds() { - -} - - diff --git a/unittest/tests/action/TestActionHelper.cpp b/unittest/tests/action/TestActionHelper.cpp index d5b2e467..944ad705 100644 --- a/unittest/tests/action/TestActionHelper.cpp +++ b/unittest/tests/action/TestActionHelper.cpp @@ -1,106 +1,107 @@ -//#include "TestActionHelper.h" -//#include -//#include -//#include -//#include "../../core/CatchDefinitions.h" -// -// -//TEST_CASE( "Action Helper" , "[ActionHelper]") { -// ActionHelperOwnerMockBase testDhMock; -// MessageQueueMockBase testMqMock; -// ActionHelper actionHelper = ActionHelper( -// &testDhMock, dynamic_cast(&testMqMock)); -// CommandMessage actionMessage; -// ActionId_t testActionId = 777; -// std::array testParams {1, 2, 3}; -// store_address_t paramAddress; -// StorageManagerIF *ipcStore = tglob::getIpcStoreHandle(); -// ipcStore->addData(¶mAddress, testParams.data(), 3); -// REQUIRE(actionHelper.initialize() == retval::CATCH_OK); -// -// SECTION ("Simple tests") { -// ActionMessage::setCommand(&actionMessage, testActionId, paramAddress); -// CHECK(not testDhMock.executeActionCalled); -// REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK); -// CHECK(testDhMock.executeActionCalled); -// // No message is sent if everything is alright. -// CHECK(not testMqMock.wasMessageSent()); -// store_address_t invalidAddress; -// ActionMessage::setCommand(&actionMessage, testActionId, invalidAddress); -// actionHelper.handleActionMessage(&actionMessage); -// CHECK(testMqMock.wasMessageSent()); -// const uint8_t* ptr = nullptr; -// size_t size = 0; -// REQUIRE(ipcStore->getData(paramAddress, &ptr, &size) == static_cast(StorageManagerIF::DATA_DOES_NOT_EXIST)); -// REQUIRE(ptr == nullptr); -// REQUIRE(size == 0); -// testDhMock.getBuffer(&ptr, &size); -// REQUIRE(size == 3); -// for(uint8_t i = 0; i<3;i++){ -// REQUIRE(ptr[i] == (i+1)); -// } -// testDhMock.clearBuffer(); -// } -// -// SECTION("Handle failures"){ -// actionMessage.setCommand(1234); -// REQUIRE(actionHelper.handleActionMessage(&actionMessage) == static_cast(CommandMessage::UNKNOWN_COMMAND)); -// CHECK(not testMqMock.wasMessageSent()); -// uint16_t step = 5; -// ReturnValue_t status = 0x1234; -// actionHelper.step(step, testMqMock.getId(), testActionId, status); -// step += 1; -// CHECK(testMqMock.wasMessageSent()); -// CommandMessage testMessage; -// REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast(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; -// REQUIRE(testMessage.getParameter2() == parameter2); -// REQUIRE(ActionMessage::getStep(&testMessage) == step); -// } -// -// SECTION("Handle finish"){ -// CHECK(not testMqMock.wasMessageSent()); -// ReturnValue_t status = 0x9876; -// actionHelper.finish(testMqMock.getId(), testActionId, status); -// CHECK(testMqMock.wasMessageSent()); -// CommandMessage testMessage; -// REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast(HasReturnvaluesIF::RETURN_OK)); -// REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::COMPLETION_FAILED)); -// REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId); -// REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast(status)); -// } -// -// 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); -// ActionMessage::setCommand(&actionMessage, testActionId, toLongParamAddress); -// CHECK(not testDhMock.executeActionCalled); -// REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK); -// REQUIRE(ipcStore->getData(toLongParamAddress).first == static_cast(StorageManagerIF::DATA_DOES_NOT_EXIST)); -// CommandMessage testMessage; -// REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast(HasReturnvaluesIF::RETURN_OK)); -// REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); -// REQUIRE(ActionMessage::getReturnCode(&testMessage) == 0xAFFE); -// REQUIRE(ActionMessage::getStep(&testMessage) == 0); -// REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId); -// } -// -// SECTION("Missing IPC Data"){ -// ActionMessage::setCommand(&actionMessage, testActionId, StorageManagerIF::INVALID_ADDRESS); -// CHECK(not testDhMock.executeActionCalled); -// REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK); -// CommandMessage testMessage; -// REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast(HasReturnvaluesIF::RETURN_OK)); -// REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); -// REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast(StorageManagerIF::ILLEGAL_STORAGE_ID)); -// REQUIRE(ActionMessage::getStep(&testMessage) == 0); -// } -// -// -// SECTION("Data Reply"){ -// -// } -//} +#include "TestActionHelper.h" +#include +#include +#include +#include "../../core/CatchDefinitions.h" + + +TEST_CASE( "Action Helper" , "[ActionHelper]") { + ActionHelperOwnerMockBase testDhMock; + MessageQueueMockBase testMqMock; + ActionHelper actionHelper = ActionHelper( + &testDhMock, dynamic_cast(&testMqMock)); + CommandMessage actionMessage; + ActionId_t testActionId = 777; + std::array testParams {1, 2, 3}; + store_address_t paramAddress; + StorageManagerIF *ipcStore = tglob::getIpcStoreHandle(); + REQUIRE(ipcStore != nullptr); + ipcStore->addData(¶mAddress, testParams.data(), 3); + REQUIRE(actionHelper.initialize() == retval::CATCH_OK); + + SECTION ("Simple tests") { + ActionMessage::setCommand(&actionMessage, testActionId, paramAddress); + CHECK(not testDhMock.executeActionCalled); + REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK); + CHECK(testDhMock.executeActionCalled); + // No message is sent if everything is alright. + CHECK(not testMqMock.wasMessageSent()); + store_address_t invalidAddress; + ActionMessage::setCommand(&actionMessage, testActionId, invalidAddress); + actionHelper.handleActionMessage(&actionMessage); + CHECK(testMqMock.wasMessageSent()); + const uint8_t* ptr = nullptr; + size_t size = 0; + REQUIRE(ipcStore->getData(paramAddress, &ptr, &size) == static_cast(StorageManagerIF::DATA_DOES_NOT_EXIST)); + REQUIRE(ptr == nullptr); + REQUIRE(size == 0); + testDhMock.getBuffer(&ptr, &size); + REQUIRE(size == 3); + for(uint8_t i = 0; i<3;i++){ + REQUIRE(ptr[i] == (i+1)); + } + testDhMock.clearBuffer(); + } + + SECTION("Handle failures"){ + actionMessage.setCommand(1234); + REQUIRE(actionHelper.handleActionMessage(&actionMessage) == static_cast(CommandMessage::UNKNOWN_COMMAND)); + CHECK(not testMqMock.wasMessageSent()); + uint16_t step = 5; + ReturnValue_t status = 0x1234; + actionHelper.step(step, testMqMock.getId(), testActionId, status); + step += 1; + CHECK(testMqMock.wasMessageSent()); + CommandMessage testMessage; + REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast(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; + REQUIRE(testMessage.getParameter2() == parameter2); + REQUIRE(ActionMessage::getStep(&testMessage) == step); + } + + SECTION("Handle finish"){ + CHECK(not testMqMock.wasMessageSent()); + ReturnValue_t status = 0x9876; + actionHelper.finish(testMqMock.getId(), testActionId, status); + CHECK(testMqMock.wasMessageSent()); + CommandMessage testMessage; + REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::COMPLETION_FAILED)); + REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId); + REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast(status)); + } + + 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); + ActionMessage::setCommand(&actionMessage, testActionId, toLongParamAddress); + CHECK(not testDhMock.executeActionCalled); + REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK); + REQUIRE(ipcStore->getData(toLongParamAddress).first == static_cast(StorageManagerIF::DATA_DOES_NOT_EXIST)); + CommandMessage testMessage; + REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); + REQUIRE(ActionMessage::getReturnCode(&testMessage) == 0xAFFE); + REQUIRE(ActionMessage::getStep(&testMessage) == 0); + REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId); + } + + SECTION("Missing IPC Data"){ + ActionMessage::setCommand(&actionMessage, testActionId, StorageManagerIF::INVALID_ADDRESS); + CHECK(not testDhMock.executeActionCalled); + REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK); + CommandMessage testMessage; + REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); + REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast(StorageManagerIF::ILLEGAL_STORAGE_ID)); + REQUIRE(ActionMessage::getStep(&testMessage) == 0); + } + + + SECTION("Data Reply"){ + + } +} diff --git a/unittest/tests/action/TestActionHelper.h b/unittest/tests/action/TestActionHelper.h index 9bc93d3e..4ba417eb 100644 --- a/unittest/tests/action/TestActionHelper.h +++ b/unittest/tests/action/TestActionHelper.h @@ -1,131 +1,132 @@ -//#ifndef UNITTEST_HOSTED_TESTACTIONHELPER_H_ -//#define UNITTEST_HOSTED_TESTACTIONHELPER_H_ -// -//#include -//#include -//#include -//#include -// -// -//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; isize; -// } -// if(ptr != nullptr){ -// *ptr = buffer; -// } -// } -//}; -// -// -//class MessageQueueMockBase: public MessageQueueIF { -//public: -// MessageQueueId_t myQueueId = 0; -// bool defaultDestSet = false; -// bool messageSent = false; -// -// -// -// bool wasMessageSent() { -// bool tempMessageSent = messageSent; -// messageSent = false; -// return tempMessageSent; -// } -// -// virtual ReturnValue_t reply( MessageQueueMessage* message ) { -// messageSent = true; -// lastMessage = (*message); -// return HasReturnvaluesIF::RETURN_OK; -// }; -// virtual ReturnValue_t receiveMessage(MessageQueueMessage* message, -// MessageQueueId_t *receivedFrom) { -// (*message) = lastMessage; -// lastMessage.clear(); -// return HasReturnvaluesIF::RETURN_OK; -// } -// virtual ReturnValue_t receiveMessage(MessageQueueMessage* message) { -// (*message) = lastMessage; -// lastMessage.clear(); -// return HasReturnvaluesIF::RETURN_OK; -// } -// virtual ReturnValue_t flush(uint32_t* count) { -// return HasReturnvaluesIF::RETURN_OK; -// } -// virtual MessageQueueId_t getLastPartner() const { -// return tconst::testQueueId; -// } -// virtual MessageQueueId_t getId() const { -// return tconst::testQueueId; -// } -// virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo, -// MessageQueueMessage* message, MessageQueueId_t sentFrom, -// bool ignoreFault = false ) { -// messageSent = true; -// lastMessage = (*message); -// return HasReturnvaluesIF::RETURN_OK; -// } -// virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo, -// MessageQueueMessage* message, bool ignoreFault = false ) override { -// messageSent = true; -// lastMessage = (*message); -// return HasReturnvaluesIF::RETURN_OK; -// } -// virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessage* message, -// MessageQueueId_t sentFrom, bool ignoreFault = false ) { -// messageSent = true; -// lastMessage = (*message); -// return HasReturnvaluesIF::RETURN_OK; -// } -// virtual ReturnValue_t sendToDefault( MessageQueueMessage* message ) { -// messageSent = true; -// lastMessage = (*message); -// return HasReturnvaluesIF::RETURN_OK; -// } -// virtual void setDefaultDestination(MessageQueueId_t defaultDestination) { -// myQueueId = defaultDestination; -// defaultDestSet = true; -// } -// -// virtual MessageQueueId_t getDefaultDestination() const { -// return myQueueId; -// } -// virtual bool isDefaultDestinationSet() const { -// return defaultDestSet; -// } -//private: -// MessageQueueMessage lastMessage; -// -//}; -// -// -//#endif /* UNITTEST_TESTFW_NEWTESTS_TESTACTIONHELPER_H_ */ +#ifndef UNITTEST_HOSTED_TESTACTIONHELPER_H_ +#define UNITTEST_HOSTED_TESTACTIONHELPER_H_ + +#include +#include +#include +#include + + +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; isize; + } + if(ptr != nullptr){ + *ptr = buffer; + } + } +}; + + +class MessageQueueMockBase: public MessageQueueIF { +public: + MessageQueueId_t myQueueId = 0; + bool defaultDestSet = false; + bool messageSent = false; + + + + bool wasMessageSent() { + bool tempMessageSent = messageSent; + messageSent = false; + return tempMessageSent; + } + + virtual ReturnValue_t reply( MessageQueueMessageIF* message ) { + messageSent = true; + lastMessage = *(dynamic_cast(message)); + return HasReturnvaluesIF::RETURN_OK; + }; + virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message, + MessageQueueId_t *receivedFrom) { + (*message) = lastMessage; + lastMessage.clear(); + return HasReturnvaluesIF::RETURN_OK; + } + virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message) { + memcpy(message->getBuffer(), lastMessage.getBuffer(), + message->getMessageSize()); + lastMessage.clear(); + return HasReturnvaluesIF::RETURN_OK; + } + virtual ReturnValue_t flush(uint32_t* count) { + return HasReturnvaluesIF::RETURN_OK; + } + virtual MessageQueueId_t getLastPartner() const { + return tconst::testQueueId; + } + virtual MessageQueueId_t getId() const { + return tconst::testQueueId; + } + virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo, + MessageQueueMessageIF* message, MessageQueueId_t sentFrom, + bool ignoreFault = false ) { + messageSent = true; + lastMessage = *(dynamic_cast(message)); + return HasReturnvaluesIF::RETURN_OK; + } + virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo, + MessageQueueMessageIF* message, bool ignoreFault = false ) override { + messageSent = true; + lastMessage = *(dynamic_cast(message)); + return HasReturnvaluesIF::RETURN_OK; + } + virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessageIF* message, + MessageQueueId_t sentFrom, bool ignoreFault = false ) { + messageSent = true; + lastMessage = *(dynamic_cast(message)); + return HasReturnvaluesIF::RETURN_OK; + } + virtual ReturnValue_t sendToDefault( MessageQueueMessageIF* message ) { + messageSent = true; + lastMessage = *(dynamic_cast(message)); + return HasReturnvaluesIF::RETURN_OK; + } + virtual void setDefaultDestination(MessageQueueId_t defaultDestination) { + myQueueId = defaultDestination; + defaultDestSet = true; + } + + virtual MessageQueueId_t getDefaultDestination() const { + return myQueueId; + } + virtual bool isDefaultDestinationSet() const { + return defaultDestSet; + } +private: + MessageQueueMessage lastMessage; + +}; + + +#endif /* UNITTEST_TESTFW_NEWTESTS_TESTACTIONHELPER_H_ */ From 9781105ad0378ee66d14d93c5994f01602a091ae Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 3 Dec 2020 14:50:28 +0100 Subject: [PATCH 19/26] moved catch factory again --- unittest/{core => testcfg}/CatchFactory.cpp | 10 +++++----- unittest/{core => testcfg}/CatchFactory.h | 0 unittest/testcfg/testcfg.mk | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) rename unittest/{core => testcfg}/CatchFactory.cpp (87%) rename unittest/{core => testcfg}/CatchFactory.h (100%) diff --git a/unittest/core/CatchFactory.cpp b/unittest/testcfg/CatchFactory.cpp similarity index 87% rename from unittest/core/CatchFactory.cpp rename to unittest/testcfg/CatchFactory.cpp index cf10e94a..c74a8126 100644 --- a/unittest/core/CatchFactory.cpp +++ b/unittest/testcfg/CatchFactory.cpp @@ -1,11 +1,11 @@ #include "CatchFactory.h" -#include "../../events/EventManager.h" -#include "../../health/HealthTable.h" +#include +#include -#include "../../internalError/InternalErrorReporter.h" -#include "../../objectmanager/frameworkObjects.h" -#include "../../storagemanager/PoolManager.h" +#include +#include +#include /** * @brief Produces system objects. diff --git a/unittest/core/CatchFactory.h b/unittest/testcfg/CatchFactory.h similarity index 100% rename from unittest/core/CatchFactory.h rename to unittest/testcfg/CatchFactory.h diff --git a/unittest/testcfg/testcfg.mk b/unittest/testcfg/testcfg.mk index 64fa87f6..31d3b60a 100644 --- a/unittest/testcfg/testcfg.mk +++ b/unittest/testcfg/testcfg.mk @@ -3,6 +3,7 @@ CXXSRC += $(wildcard $(CURRENTPATH)/ipc/*.cpp) CXXSRC += $(wildcard $(CURRENTPATH)/objects/*.cpp) CXXSRC += $(wildcard $(CURRENTPATH)/pollingsequence/*.cpp) CXXSRC += $(wildcard $(CURRENTPATH)/events/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/*.cpp) INCLUDES += $(CURRENTPATH) INCLUDES += $(CURRENTPATH)/objects From 983556b3b3c70b9d4c337ebfc44cbe0290da96ec Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 5 Dec 2020 01:21:04 +0100 Subject: [PATCH 20/26] evil bug fixed --- osal/host/MessageQueue.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osal/host/MessageQueue.cpp b/osal/host/MessageQueue.cpp index bced3713..f1f5867b 100644 --- a/osal/host/MessageQueue.cpp +++ b/osal/host/MessageQueue.cpp @@ -34,7 +34,7 @@ ReturnValue_t MessageQueue::sendToDefaultFrom(MessageQueueMessageIF* message, } ReturnValue_t MessageQueue::reply(MessageQueueMessageIF* message) { - if (this->lastPartner != 0) { + if (this->lastPartner != MessageQueueIF::NO_QUEUE) { return sendMessageFrom(this->lastPartner, message, this->getId()); } else { return MessageQueueIF::NO_REPLY_PARTNER; @@ -106,6 +106,7 @@ bool MessageQueue::isDefaultDestinationSet() const { ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, MessageQueueMessageIF* message, MessageQueueId_t sentFrom, bool ignoreFault) { + message->setSender(sentFrom); if(message->getMessageSize() > message->getMaximumMessageSize()) { // Actually, this should never happen or an error will be emitted // in MessageQueueMessage. @@ -126,7 +127,6 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, // TODO: Better returnvalue return HasReturnvaluesIF::RETURN_FAILED; } - if(targetQueue->messageQueue.size() < targetQueue->messageDepth) { MutexHelper mutexLock(targetQueue->queueLock, MutexIF::TimeoutType::WAITING, 20); @@ -145,7 +145,6 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, else { return MessageQueueIF::FULL; } - message->setSender(sentFrom); return HasReturnvaluesIF::RETURN_OK; } From bb11bc5685e54366c819803c8ec5655ba4acdc4d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 5 Dec 2020 17:11:34 +0100 Subject: [PATCH 21/26] task if is set now --- osal/host/PeriodicTask.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/osal/host/PeriodicTask.cpp b/osal/host/PeriodicTask.cpp index 5662c7cc..bfa6c3fd 100644 --- a/osal/host/PeriodicTask.cpp +++ b/osal/host/PeriodicTask.cpp @@ -122,6 +122,7 @@ ReturnValue_t PeriodicTask::addComponent(object_id_t object) { if (newObject == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } + newObject->setTaskIF(this); objectList.push_back(newObject); return HasReturnvaluesIF::RETURN_OK; } From 2a025de321396315ac1119d0f5e46d9abdc95249 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Dec 2020 14:19:53 +0100 Subject: [PATCH 22/26] changelog update --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index c221c811..2d1152c7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,4 +14,4 @@ a C file without issues ### Events -- makeEvent function: Not takes three input parameters instead of two and allows setting a unique ID +- makeEvent function: Now takes three input parameters instead of two and allows setting a unique ID From fdbe5408b7b5924ee431206d5cdc32c47a3374b8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Dec 2020 14:43:44 +0100 Subject: [PATCH 23/26] renamed namespaces --- datalinklayer/DataLinkLayer.h | 12 +++--- datapool/HkSwitchHelper.h | 2 +- .../DeviceHandlerFailureIsolation.cpp | 6 +-- devicehandlers/DeviceHandlerIF.h | 22 +++++----- events/Event.h | 43 ++++++++----------- events/EventManager.cpp | 2 +- fdir/FailureIsolationBase.cpp | 4 +- fdir/FailureIsolationBase.h | 6 +-- health/HasHealthIF.h | 14 +++--- modes/HasModesIF.h | 16 +++---- monitoring/MonitoringIF.h | 8 ++-- power/Fuse.h | 8 ++-- power/PowerSwitchIF.h | 2 +- pus/Service17Test.h | 2 +- pus/Service9TimeManagement.h | 4 +- storagemanager/StorageManagerIF.h | 4 +- thermal/AbstractTemperatureSensor.h | 6 +-- thermal/Heater.h | 10 ++--- thermal/ThermalComponentIF.h | 10 ++--- tmstorage/TmStoreBackendIF.h | 32 +++++++------- 20 files changed, 104 insertions(+), 109 deletions(-) diff --git a/datalinklayer/DataLinkLayer.h b/datalinklayer/DataLinkLayer.h index 5a900099..17a57d61 100644 --- a/datalinklayer/DataLinkLayer.h +++ b/datalinklayer/DataLinkLayer.h @@ -19,12 +19,12 @@ class VirtualChannelReception; class DataLinkLayer : public CCSDSReturnValuesIF { public: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYSTEM_1; - static const Event RF_AVAILABLE = MAKE_EVENT(0, SEVERITY::INFO); //!< A RF available signal was detected. P1: raw RFA state, P2: 0 - static const Event RF_LOST = MAKE_EVENT(1, SEVERITY::INFO); //!< A previously found RF available signal was lost. P1: raw RFA state, P2: 0 - static const Event BIT_LOCK = MAKE_EVENT(2, SEVERITY::INFO); //!< A Bit Lock signal. Was detected. P1: raw BLO state, P2: 0 - static const Event BIT_LOCK_LOST = MAKE_EVENT(3, SEVERITY::INFO); //!< A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0 -// static const Event RF_CHAIN_LOST = MAKE_EVENT(4, SEVERITY::INFO); //!< The CCSDS Board detected that either bit lock or RF available or both are lost. No parameters. - static const Event FRAME_PROCESSING_FAILED = MAKE_EVENT(5, SEVERITY::LOW); //!< The CCSDS Board could not interpret a TC + static const Event RF_AVAILABLE = MAKE_EVENT(0, severity::INFO); //!< A RF available signal was detected. P1: raw RFA state, P2: 0 + static const Event RF_LOST = MAKE_EVENT(1, severity::INFO); //!< A previously found RF available signal was lost. P1: raw RFA state, P2: 0 + static const Event BIT_LOCK = MAKE_EVENT(2, severity::INFO); //!< A Bit Lock signal. Was detected. P1: raw BLO state, P2: 0 + static const Event BIT_LOCK_LOST = MAKE_EVENT(3, severity::INFO); //!< A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0 +// static const Event RF_CHAIN_LOST = MAKE_EVENT(4, severity::INFO); //!< The CCSDS Board detected that either bit lock or RF available or both are lost. No parameters. + static const Event FRAME_PROCESSING_FAILED = MAKE_EVENT(5, severity::LOW); //!< The CCSDS Board could not interpret a TC /** * The Constructor sets the passed parameters and nothing else. * @param set_frame_buffer The buffer in which incoming frame candidates are stored. diff --git a/datapool/HkSwitchHelper.h b/datapool/HkSwitchHelper.h index 385b2047..bb9e7dc6 100644 --- a/datapool/HkSwitchHelper.h +++ b/datapool/HkSwitchHelper.h @@ -13,7 +13,7 @@ class HkSwitchHelper: public ExecutableObjectIF, public CommandsActionsIF { public: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HK; - static const Event SWITCHING_TM_FAILED = MAKE_EVENT(1, SEVERITY::LOW); //!< Commanding the HK Service failed, p1: error code, p2 action: 0 disable / 1 enable + static const Event SWITCHING_TM_FAILED = MAKE_EVENT(1, severity::LOW); //!< Commanding the HK Service failed, p1: error code, p2 action: 0 disable / 1 enable HkSwitchHelper(EventReportingProxyIF *eventProxy); virtual ~HkSwitchHelper(); diff --git a/devicehandlers/DeviceHandlerFailureIsolation.cpp b/devicehandlers/DeviceHandlerFailureIsolation.cpp index 9fbe71d8..f4966351 100644 --- a/devicehandlers/DeviceHandlerFailureIsolation.cpp +++ b/devicehandlers/DeviceHandlerFailureIsolation.cpp @@ -191,7 +191,7 @@ void DeviceHandlerFailureIsolation::triggerEvent(Event event, uint32_t parameter uint32_t parameter2) { //Do not throw error events if fdirState != none. //This will still forward MODE and HEALTH INFO events in any case. - if (fdirState == NONE || EVENT::getSeverity(event) == SEVERITY::INFO) { + if (fdirState == NONE || event::getSeverity(event) == severity::INFO) { FailureIsolationBase::triggerEvent(event, parameter1, parameter2); } } @@ -201,7 +201,7 @@ bool DeviceHandlerFailureIsolation::isFdirActionInProgress() { } void DeviceHandlerFailureIsolation::startRecovery(Event reason) { - throwFdirEvent(FDIR_STARTS_RECOVERY, EVENT::getEventId(reason)); + throwFdirEvent(FDIR_STARTS_RECOVERY, event::getEventId(reason)); setOwnerHealth(HasHealthIF::NEEDS_RECOVERY); setFdirState(RECOVERY_ONGOING); } @@ -228,7 +228,7 @@ ReturnValue_t DeviceHandlerFailureIsolation::getParameter(uint8_t domainId, } void DeviceHandlerFailureIsolation::setFaulty(Event reason) { - throwFdirEvent(FDIR_TURNS_OFF_DEVICE, EVENT::getEventId(reason)); + throwFdirEvent(FDIR_TURNS_OFF_DEVICE, event::getEventId(reason)); setOwnerHealth(HasHealthIF::FAULTY); setFdirState(AWAIT_SHUTDOWN); } diff --git a/devicehandlers/DeviceHandlerIF.h b/devicehandlers/DeviceHandlerIF.h index 35bbe376..39a0e39a 100644 --- a/devicehandlers/DeviceHandlerIF.h +++ b/devicehandlers/DeviceHandlerIF.h @@ -83,17 +83,17 @@ public: static const Mode_t _MODE_SWITCH_IS_OFF = TRANSITION_MODE_BASE_ACTION_MASK | 5; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CDH; - static const Event DEVICE_BUILDING_COMMAND_FAILED = MAKE_EVENT(0, SEVERITY::LOW); - static const Event DEVICE_SENDING_COMMAND_FAILED = MAKE_EVENT(1, SEVERITY::LOW); - static const Event DEVICE_REQUESTING_REPLY_FAILED = MAKE_EVENT(2, SEVERITY::LOW); - static const Event DEVICE_READING_REPLY_FAILED = MAKE_EVENT(3, SEVERITY::LOW); - static const Event DEVICE_INTERPRETING_REPLY_FAILED = MAKE_EVENT(4, SEVERITY::LOW); - static const Event DEVICE_MISSED_REPLY = MAKE_EVENT(5, SEVERITY::LOW); - static const Event DEVICE_UNKNOWN_REPLY = MAKE_EVENT(6, SEVERITY::LOW); - static const Event DEVICE_UNREQUESTED_REPLY = MAKE_EVENT(7, SEVERITY::LOW); - static const Event INVALID_DEVICE_COMMAND = MAKE_EVENT(8, SEVERITY::LOW); //!< Indicates a SW bug in child class. - static const Event MONITORING_LIMIT_EXCEEDED = MAKE_EVENT(9, SEVERITY::LOW); - static const Event MONITORING_AMBIGUOUS = MAKE_EVENT(10, SEVERITY::HIGH); + static const Event DEVICE_BUILDING_COMMAND_FAILED = MAKE_EVENT(0, severity::LOW); + static const Event DEVICE_SENDING_COMMAND_FAILED = MAKE_EVENT(1, severity::LOW); + static const Event DEVICE_REQUESTING_REPLY_FAILED = MAKE_EVENT(2, severity::LOW); + static const Event DEVICE_READING_REPLY_FAILED = MAKE_EVENT(3, severity::LOW); + static const Event DEVICE_INTERPRETING_REPLY_FAILED = MAKE_EVENT(4, severity::LOW); + static const Event DEVICE_MISSED_REPLY = MAKE_EVENT(5, severity::LOW); + static const Event DEVICE_UNKNOWN_REPLY = MAKE_EVENT(6, severity::LOW); + static const Event DEVICE_UNREQUESTED_REPLY = MAKE_EVENT(7, severity::LOW); + static const Event INVALID_DEVICE_COMMAND = MAKE_EVENT(8, severity::LOW); //!< Indicates a SW bug in child class. + static const Event MONITORING_LIMIT_EXCEEDED = MAKE_EVENT(9, severity::LOW); + static const Event MONITORING_AMBIGUOUS = MAKE_EVENT(10, severity::HIGH); static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_IF; diff --git a/events/Event.h b/events/Event.h index 90ff1a90..aebc4bc5 100644 --- a/events/Event.h +++ b/events/Event.h @@ -3,7 +3,7 @@ #include #include "fwSubsystemIdRanges.h" -//could be move to more suitable location +// could be moved to more suitable location #include typedef uint16_t EventId_t; @@ -13,33 +13,28 @@ typedef uint8_t EventSeverity_t; typedef uint32_t Event; -namespace EVENT { -EventId_t getEventId(Event event); +namespace event { -EventSeverity_t getSeverity(Event event); - -Event makeEvent(uint8_t subsystemId, uint8_t uniqueEventId, - EventSeverity_t eventSeverity); +constexpr EventId_t getEventId(Event event) { + return (event & 0xFFFF); } -namespace SEVERITY { - static const EventSeverity_t INFO = 1; - static const EventSeverity_t LOW = 2; - static const EventSeverity_t MEDIUM = 3; - static const EventSeverity_t HIGH = 4; +constexpr EventSeverity_t getSeverity(Event event) { + return ((event >> 16) & 0xFF); } -//Unfortunately, this does not work nicely because of the inability to define static classes in headers. -//struct Event { -// Event(uint8_t domain, uint8_t counter, EventSeverity_t severity) : -// id(domain*100+counter), severity(severity) { -// } -// EventId_t id; -// EventSeverity_t severity; -// static const EventSeverity_t INFO = 1; -// static const EventSeverity_t LOW = 2; -// static const EventSeverity_t MEDIUM = 3; -// static const EventSeverity_t HIGH = 4; -//}; +constexpr Event makeEvent(uint8_t subsystemId, uint8_t uniqueEventId, + EventSeverity_t eventSeverity) { + return (eventSeverity << 16) + (subsystemId * 100) + uniqueEventId; +} + +} + +namespace severity { + static constexpr EventSeverity_t INFO = 1; + static constexpr EventSeverity_t LOW = 2; + static constexpr EventSeverity_t MEDIUM = 3; + static constexpr EventSeverity_t HIGH = 4; +} #endif /* EVENTOBJECT_EVENT_H_ */ diff --git a/events/EventManager.cpp b/events/EventManager.cpp index f60a8a66..71d1e2e6 100644 --- a/events/EventManager.cpp +++ b/events/EventManager.cpp @@ -118,7 +118,7 @@ ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener, void EventManager::printEvent(EventMessage* message) { const char *string = 0; switch (message->getSeverity()) { - case SEVERITY::INFO: + case severity::INFO: #ifdef DEBUG_INFO_EVENT string = translateObject(message->getReporter()); sif::info << "EVENT: "; diff --git a/fdir/FailureIsolationBase.cpp b/fdir/FailureIsolationBase.cpp index f3b34f0f..a04a0313 100644 --- a/fdir/FailureIsolationBase.cpp +++ b/fdir/FailureIsolationBase.cpp @@ -139,7 +139,7 @@ void FailureIsolationBase::triggerEvent(Event event, uint32_t parameter1, uint32_t parameter2) { //With this mechanism, all events are disabled for a certain device. //That's not so good for visibility. - if (isFdirDisabledForSeverity(EVENT::getSeverity(event))) { + if (isFdirDisabledForSeverity(event::getSeverity(event))) { return; } EventMessage message(event, ownerId, parameter1, parameter2); @@ -148,7 +148,7 @@ void FailureIsolationBase::triggerEvent(Event event, uint32_t parameter1, } bool FailureIsolationBase::isFdirDisabledForSeverity(EventSeverity_t severity) { - if ((owner != NULL) && (severity != SEVERITY::INFO)) { + if ((owner != NULL) && (severity != severity::INFO)) { if (owner->getHealth() == HasHealthIF::EXTERNAL_CONTROL) { //External control disables handling of fault messages. return true; diff --git a/fdir/FailureIsolationBase.h b/fdir/FailureIsolationBase.h index 5b2c099a..4a3f5adf 100644 --- a/fdir/FailureIsolationBase.h +++ b/fdir/FailureIsolationBase.h @@ -14,9 +14,9 @@ class FailureIsolationBase: public HasReturnvaluesIF, public HasParametersIF { public: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FDIR_1; - static const Event FDIR_CHANGED_STATE = MAKE_EVENT(1, SEVERITY::INFO); //!< FDIR has an internal state, which changed from par2 (oldState) to par1 (newState). - static const Event FDIR_STARTS_RECOVERY = MAKE_EVENT(2, SEVERITY::MEDIUM); //!< FDIR tries to restart device. Par1: event that caused recovery. - static const Event FDIR_TURNS_OFF_DEVICE = MAKE_EVENT(3, SEVERITY::MEDIUM); //!< FDIR turns off device. Par1: event that caused recovery. + static const Event FDIR_CHANGED_STATE = MAKE_EVENT(1, severity::INFO); //!< FDIR has an internal state, which changed from par2 (oldState) to par1 (newState). + static const Event FDIR_STARTS_RECOVERY = MAKE_EVENT(2, severity::MEDIUM); //!< FDIR tries to restart device. Par1: event that caused recovery. + static const Event FDIR_TURNS_OFF_DEVICE = MAKE_EVENT(3, severity::MEDIUM); //!< FDIR turns off device. Par1: event that caused recovery. FailureIsolationBase(object_id_t owner, object_id_t parent = objects::NO_OBJECT, diff --git a/health/HasHealthIF.h b/health/HasHealthIF.h index 86863ea8..a6254e39 100644 --- a/health/HasHealthIF.h +++ b/health/HasHealthIF.h @@ -21,13 +21,13 @@ public: static const ReturnValue_t INVALID_HEALTH_STATE = MAKE_RETURN_CODE(2); static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYSTEM_MANAGER_1; - 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. + 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. virtual ~HasHealthIF() { } diff --git a/modes/HasModesIF.h b/modes/HasModesIF.h index 34a15937..c29a0a96 100644 --- a/modes/HasModesIF.h +++ b/modes/HasModesIF.h @@ -18,14 +18,14 @@ public: static const ReturnValue_t INVALID_SUBMODE = MAKE_RETURN_CODE(0x04); static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYSTEM_MANAGER; - static const Event CHANGING_MODE = MAKE_EVENT(0, SEVERITY::INFO); //!< An object announces changing the mode. p1: target mode. p2: target submode - static const Event MODE_INFO = MAKE_EVENT(1, SEVERITY::INFO); //!< An Object announces its mode; parameter1 is mode, parameter2 is submode - static const Event FALLBACK_FAILED = MAKE_EVENT(2, SEVERITY::HIGH); - static const Event MODE_TRANSITION_FAILED = MAKE_EVENT(3, SEVERITY::LOW); - static const Event CANT_KEEP_MODE = MAKE_EVENT(4, SEVERITY::HIGH); - static const Event OBJECT_IN_INVALID_MODE = MAKE_EVENT(5, SEVERITY::LOW); //!< Indicates a bug or configuration failure: Object is in a mode it should never be in. - static const Event FORCING_MODE = MAKE_EVENT(6, SEVERITY::MEDIUM); //!< The mode is changed, but for some reason, the change is forced, i.e. EXTERNAL_CONTROL ignored. p1: target mode. p2: target submode - static const Event MODE_CMD_REJECTED = MAKE_EVENT(7, SEVERITY::LOW); //!< A mode command was rejected by the called object. Par1: called object id, Par2: return code. + static const Event CHANGING_MODE = MAKE_EVENT(0, severity::INFO); //!< An object announces changing the mode. p1: target mode. p2: target submode + static const Event MODE_INFO = MAKE_EVENT(1, severity::INFO); //!< An Object announces its mode; parameter1 is mode, parameter2 is submode + static const Event FALLBACK_FAILED = MAKE_EVENT(2, severity::HIGH); + static const Event MODE_TRANSITION_FAILED = MAKE_EVENT(3, severity::LOW); + static const Event CANT_KEEP_MODE = MAKE_EVENT(4, severity::HIGH); + static const Event OBJECT_IN_INVALID_MODE = MAKE_EVENT(5, severity::LOW); //!< Indicates a bug or configuration failure: Object is in a mode it should never be in. + static const Event FORCING_MODE = MAKE_EVENT(6, severity::MEDIUM); //!< The mode is changed, but for some reason, the change is forced, i.e. EXTERNAL_CONTROL ignored. p1: target mode. p2: target submode + static const Event MODE_CMD_REJECTED = MAKE_EVENT(7, severity::LOW); //!< A mode command was rejected by the called object. Par1: called object id, Par2: return code. static const Mode_t MODE_ON = 1; //!< The device is powered and ready to perform operations. In this mode, no commands are sent by the device handler itself, but direct commands van be commanded and will be interpreted static const Mode_t MODE_OFF = 0; //!< The device is powered off. The only command accepted in this mode is a mode change to on. diff --git a/monitoring/MonitoringIF.h b/monitoring/MonitoringIF.h index 44218c36..040539ef 100644 --- a/monitoring/MonitoringIF.h +++ b/monitoring/MonitoringIF.h @@ -15,10 +15,10 @@ public: static const uint8_t LIMIT_TYPE_OBJECT = 128; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FDIR_2; - static const Event MONITOR_CHANGED_STATE = MAKE_EVENT(1, SEVERITY::LOW); - static const Event VALUE_BELOW_LOW_LIMIT = MAKE_EVENT(2, SEVERITY::LOW); - static const Event VALUE_ABOVE_HIGH_LIMIT = MAKE_EVENT(3, SEVERITY::LOW); - static const Event VALUE_OUT_OF_RANGE = MAKE_EVENT(4, SEVERITY::LOW); + static const Event MONITOR_CHANGED_STATE = MAKE_EVENT(1, severity::LOW); + static const Event VALUE_BELOW_LOW_LIMIT = MAKE_EVENT(2, severity::LOW); + static const Event VALUE_ABOVE_HIGH_LIMIT = MAKE_EVENT(3, severity::LOW); + static const Event VALUE_OUT_OF_RANGE = MAKE_EVENT(4, severity::LOW); static const uint8_t INTERFACE_ID = CLASS_ID::LIMITS_IF; static const ReturnValue_t UNCHECKED = MAKE_RETURN_CODE(1); diff --git a/power/Fuse.h b/power/Fuse.h index 279642be..c67f69cc 100644 --- a/power/Fuse.h +++ b/power/Fuse.h @@ -32,10 +32,10 @@ public: }; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PCDU_1; - static const Event FUSE_CURRENT_HIGH = MAKE_EVENT(1, SEVERITY::LOW); //!< PSS detected that current on a fuse is totally out of bounds. - static const Event FUSE_WENT_OFF = MAKE_EVENT(2, SEVERITY::LOW); //!< PSS detected a fuse that went off. - static const Event POWER_ABOVE_HIGH_LIMIT = MAKE_EVENT(4, SEVERITY::LOW); //!< PSS detected a fuse that violates its limits. - static const Event POWER_BELOW_LOW_LIMIT = MAKE_EVENT(5, SEVERITY::LOW); //!< PSS detected a fuse that violates its limits. + static const Event FUSE_CURRENT_HIGH = MAKE_EVENT(1, severity::LOW); //!< PSS detected that current on a fuse is totally out of bounds. + static const Event FUSE_WENT_OFF = MAKE_EVENT(2, severity::LOW); //!< PSS detected a fuse that went off. + static const Event POWER_ABOVE_HIGH_LIMIT = MAKE_EVENT(4, severity::LOW); //!< PSS detected a fuse that violates its limits. + static const Event POWER_BELOW_LOW_LIMIT = MAKE_EVENT(5, severity::LOW); //!< PSS detected a fuse that violates its limits. typedef std::list DeviceList; Fuse(object_id_t fuseObjectId, uint8_t fuseId, VariableIds ids, diff --git a/power/PowerSwitchIF.h b/power/PowerSwitchIF.h index 40220fb6..c6e4b257 100644 --- a/power/PowerSwitchIF.h +++ b/power/PowerSwitchIF.h @@ -32,7 +32,7 @@ public: 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 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 /** * send a direct command to the Power Unit to enable/disable the specified switch. * diff --git a/pus/Service17Test.h b/pus/Service17Test.h index e2681865..83d436ea 100644 --- a/pus/Service17Test.h +++ b/pus/Service17Test.h @@ -21,7 +21,7 @@ class Service17Test: public PusServiceBase { public: // Custom events which can be triggered static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_17; - static constexpr Event TEST = MAKE_EVENT(0, SEVERITY::INFO); + static constexpr Event TEST = MAKE_EVENT(0, severity::INFO); enum Subservice: uint8_t { //! [EXPORT] : [COMMAND] Perform connection test diff --git a/pus/Service9TimeManagement.h b/pus/Service9TimeManagement.h index 4802cdec..70b86966 100644 --- a/pus/Service9TimeManagement.h +++ b/pus/Service9TimeManagement.h @@ -7,8 +7,8 @@ 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. + 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. static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_9; diff --git a/storagemanager/StorageManagerIF.h b/storagemanager/StorageManagerIF.h index 834e7563..ab1998bf 100644 --- a/storagemanager/StorageManagerIF.h +++ b/storagemanager/StorageManagerIF.h @@ -37,8 +37,8 @@ public: static const ReturnValue_t POOL_TOO_LARGE = MAKE_RETURN_CODE(6); //!< Pool size too large on initialization. static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::OBSW; - static const Event GET_DATA_FAILED = MAKE_EVENT(0, SEVERITY::LOW); - static const Event STORE_DATA_FAILED = MAKE_EVENT(1, SEVERITY::LOW); + static const Event GET_DATA_FAILED = MAKE_EVENT(0, severity::LOW); + static const Event STORE_DATA_FAILED = MAKE_EVENT(1, severity::LOW); static const uint32_t INVALID_ADDRESS = 0xFFFFFFFF; //!< Indicates an invalid (i.e unused) storage address. /** diff --git a/thermal/AbstractTemperatureSensor.h b/thermal/AbstractTemperatureSensor.h index 726ab9f4..eaca48fb 100644 --- a/thermal/AbstractTemperatureSensor.h +++ b/thermal/AbstractTemperatureSensor.h @@ -17,9 +17,9 @@ class AbstractTemperatureSensor: public HasHealthIF, public: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::T_SENSORS; - static const Event TEMP_SENSOR_HIGH = MAKE_EVENT(0, SEVERITY::LOW); - static const Event TEMP_SENSOR_LOW = MAKE_EVENT(1, SEVERITY::LOW); - static const Event TEMP_SENSOR_GRADIENT = MAKE_EVENT(2, SEVERITY::LOW); + static const Event TEMP_SENSOR_HIGH = MAKE_EVENT(0, severity::LOW); + static const Event TEMP_SENSOR_LOW = MAKE_EVENT(1, severity::LOW); + static const Event TEMP_SENSOR_GRADIENT = MAKE_EVENT(2, severity::LOW); static constexpr float ZERO_KELVIN_C = -273.15; AbstractTemperatureSensor(object_id_t setObjectid, diff --git a/thermal/Heater.h b/thermal/Heater.h index 63fe2066..b034dfee 100644 --- a/thermal/Heater.h +++ b/thermal/Heater.h @@ -14,11 +14,11 @@ class Heater: public HealthDevice, public ReceivesParameterMessagesIF { public: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::HEATER; - static const Event HEATER_ON = MAKE_EVENT(0, SEVERITY::INFO); - static const Event HEATER_OFF = MAKE_EVENT(1, SEVERITY::INFO); - static const Event HEATER_TIMEOUT = MAKE_EVENT(2, SEVERITY::LOW); - static const Event HEATER_STAYED_ON = MAKE_EVENT(3, SEVERITY::LOW); - static const Event HEATER_STAYED_OFF = MAKE_EVENT(4, SEVERITY::LOW); + static const Event HEATER_ON = MAKE_EVENT(0, severity::INFO); + static const Event HEATER_OFF = MAKE_EVENT(1, severity::INFO); + static const Event HEATER_TIMEOUT = MAKE_EVENT(2, severity::LOW); + static const Event HEATER_STAYED_ON = MAKE_EVENT(3, severity::LOW); + static const Event HEATER_STAYED_OFF = MAKE_EVENT(4, severity::LOW); Heater(uint32_t objectId, uint8_t switch0, uint8_t switch1); virtual ~Heater(); diff --git a/thermal/ThermalComponentIF.h b/thermal/ThermalComponentIF.h index 522d4e44..e542c842 100644 --- a/thermal/ThermalComponentIF.h +++ b/thermal/ThermalComponentIF.h @@ -10,11 +10,11 @@ class ThermalComponentIF : public HasParametersIF { public: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::TCS_1; - static const Event COMPONENT_TEMP_LOW = MAKE_EVENT(1, SEVERITY::LOW); - static const Event COMPONENT_TEMP_HIGH = MAKE_EVENT(2, SEVERITY::LOW); - static const Event COMPONENT_TEMP_OOL_LOW = MAKE_EVENT(3, SEVERITY::LOW); - static const Event COMPONENT_TEMP_OOL_HIGH = MAKE_EVENT(4, SEVERITY::LOW); - static const Event TEMP_NOT_IN_OP_RANGE = MAKE_EVENT(5, SEVERITY::LOW); //!< Is thrown when a device should start-up, but the temperature is out of OP range. P1: thermalState of the component, P2: 0 + static const Event COMPONENT_TEMP_LOW = MAKE_EVENT(1, severity::LOW); + static const Event COMPONENT_TEMP_HIGH = MAKE_EVENT(2, severity::LOW); + static const Event COMPONENT_TEMP_OOL_LOW = MAKE_EVENT(3, severity::LOW); + static const Event COMPONENT_TEMP_OOL_HIGH = MAKE_EVENT(4, severity::LOW); + static const Event TEMP_NOT_IN_OP_RANGE = MAKE_EVENT(5, severity::LOW); //!< Is thrown when a device should start-up, but the temperature is out of OP range. P1: thermalState of the component, P2: 0 static const uint8_t INTERFACE_ID = CLASS_ID::THERMAL_COMPONENT_IF; static const ReturnValue_t INVALID_TARGET_STATE = MAKE_RETURN_CODE(1); diff --git a/tmstorage/TmStoreBackendIF.h b/tmstorage/TmStoreBackendIF.h index a441808e..4b2a8836 100644 --- a/tmstorage/TmStoreBackendIF.h +++ b/tmstorage/TmStoreBackendIF.h @@ -31,22 +31,22 @@ public: static const ReturnValue_t INVALID_REQUEST = MAKE_RETURN_CODE(15); static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::MEMORY; - static const Event STORE_SEND_WRITE_FAILED = MAKE_EVENT(0, SEVERITY::LOW); //!< Initiating sending data to store failed. Low, par1: returnCode, par2: integer (debug info) - static const Event STORE_WRITE_FAILED = MAKE_EVENT(1, SEVERITY::LOW); //!< Data was sent, but writing failed. Low, par1: returnCode, par2: 0 - static const Event STORE_SEND_READ_FAILED = MAKE_EVENT(2, SEVERITY::LOW); //!< Initiating reading data from store failed. Low, par1: returnCode, par2: 0 - static const Event STORE_READ_FAILED = MAKE_EVENT(3, SEVERITY::LOW); //!< Data was requested, but access failed. Low, par1: returnCode, par2: 0 - static const Event UNEXPECTED_MSG = MAKE_EVENT(4, SEVERITY::LOW); //!< An unexpected TM packet or data message occurred. Low, par1: 0, par2: integer (debug info) - static const Event STORING_FAILED = MAKE_EVENT(5, SEVERITY::LOW); //!< Storing data failed. May simply be a full store. Low, par1: returnCode, par2: integer (sequence count of failed packet). - static const Event TM_DUMP_FAILED = MAKE_EVENT(6, SEVERITY::LOW); //!< Dumping retrieved data failed. Low, par1: returnCode, par2: integer (sequence count of failed packet). - static const Event STORE_INIT_FAILED = MAKE_EVENT(7, SEVERITY::LOW); //!< Corrupted init data or read error. Low, par1: returnCode, par2: integer (debug info) - static const Event STORE_INIT_EMPTY = MAKE_EVENT(8, SEVERITY::INFO); //!< Store was not initialized. Starts empty. Info, parameters both zero. - static const Event STORE_CONTENT_CORRUPTED = MAKE_EVENT(9, SEVERITY::LOW); //!< Data was read out, but it is inconsistent. Low par1: Memory address of corruption, par2: integer (debug info) - static const Event STORE_INITIALIZE = MAKE_EVENT(10, SEVERITY::INFO); //!< Info event indicating the store will be initialized, either at boot or after IOB switch. Info. pars: 0 - static const Event INIT_DONE = MAKE_EVENT(11, SEVERITY::INFO); //!< Info event indicating the store was successfully initialized, either at boot or after IOB switch. Info. pars: 0 - static const Event DUMP_FINISHED = MAKE_EVENT(12, SEVERITY::INFO); //!< Info event indicating that dumping finished successfully. par1: Number of dumped packets. par2: APID/SSC (16bits each) - static const Event DELETION_FINISHED = MAKE_EVENT(13, SEVERITY::INFO); //!< Info event indicating that deletion finished successfully. par1: Number of deleted packets. par2: APID/SSC (16bits each) - static const Event DELETION_FAILED = MAKE_EVENT(14, SEVERITY::LOW); //!< Info event indicating that something went wrong during deletion. pars: 0 - static const Event AUTO_CATALOGS_SENDING_FAILED = MAKE_EVENT(15, SEVERITY::INFO);//!< Info that the a auto catalog report failed + static const Event STORE_SEND_WRITE_FAILED = MAKE_EVENT(0, severity::LOW); //!< Initiating sending data to store failed. Low, par1: returnCode, par2: integer (debug info) + static const Event STORE_WRITE_FAILED = MAKE_EVENT(1, severity::LOW); //!< Data was sent, but writing failed. Low, par1: returnCode, par2: 0 + static const Event STORE_SEND_READ_FAILED = MAKE_EVENT(2, severity::LOW); //!< Initiating reading data from store failed. Low, par1: returnCode, par2: 0 + static const Event STORE_READ_FAILED = MAKE_EVENT(3, severity::LOW); //!< Data was requested, but access failed. Low, par1: returnCode, par2: 0 + static const Event UNEXPECTED_MSG = MAKE_EVENT(4, severity::LOW); //!< An unexpected TM packet or data message occurred. Low, par1: 0, par2: integer (debug info) + static const Event STORING_FAILED = MAKE_EVENT(5, severity::LOW); //!< Storing data failed. May simply be a full store. Low, par1: returnCode, par2: integer (sequence count of failed packet). + static const Event TM_DUMP_FAILED = MAKE_EVENT(6, severity::LOW); //!< Dumping retrieved data failed. Low, par1: returnCode, par2: integer (sequence count of failed packet). + static const Event STORE_INIT_FAILED = MAKE_EVENT(7, severity::LOW); //!< Corrupted init data or read error. Low, par1: returnCode, par2: integer (debug info) + static const Event STORE_INIT_EMPTY = MAKE_EVENT(8, severity::INFO); //!< Store was not initialized. Starts empty. Info, parameters both zero. + static const Event STORE_CONTENT_CORRUPTED = MAKE_EVENT(9, severity::LOW); //!< Data was read out, but it is inconsistent. Low par1: Memory address of corruption, par2: integer (debug info) + static const Event STORE_INITIALIZE = MAKE_EVENT(10, severity::INFO); //!< Info event indicating the store will be initialized, either at boot or after IOB switch. Info. pars: 0 + static const Event INIT_DONE = MAKE_EVENT(11, severity::INFO); //!< Info event indicating the store was successfully initialized, either at boot or after IOB switch. Info. pars: 0 + static const Event DUMP_FINISHED = MAKE_EVENT(12, severity::INFO); //!< Info event indicating that dumping finished successfully. par1: Number of dumped packets. par2: APID/SSC (16bits each) + static const Event DELETION_FINISHED = MAKE_EVENT(13, severity::INFO); //!< Info event indicating that deletion finished successfully. par1: Number of deleted packets. par2: APID/SSC (16bits each) + static const Event DELETION_FAILED = MAKE_EVENT(14, severity::LOW); //!< Info event indicating that something went wrong during deletion. pars: 0 + static const Event AUTO_CATALOGS_SENDING_FAILED = MAKE_EVENT(15, severity::INFO);//!< Info that the a auto catalog report failed virtual ~TmStoreBackendIF() {} virtual ReturnValue_t performOperation(uint8_t opCode) = 0; From 7d70cce4dec572ca0db9012dfed4ddee31767a48 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Dec 2020 14:45:43 +0100 Subject: [PATCH 24/26] namepsace fix --- events/EventMessage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/events/EventMessage.cpp b/events/EventMessage.cpp index b911abab..bbc41e10 100644 --- a/events/EventMessage.cpp +++ b/events/EventMessage.cpp @@ -48,7 +48,7 @@ void EventMessage::setMessageId(uint8_t id) { EventSeverity_t EventMessage::getSeverity() { Event event; memcpy(&event, getData(), sizeof(Event)); - return EVENT::getSeverity(event); + return event::getSeverity(event); } void EventMessage::setSeverity(EventSeverity_t severity) { @@ -61,7 +61,7 @@ void EventMessage::setSeverity(EventSeverity_t severity) { EventId_t EventMessage::getEventId() { Event event; memcpy(&event, getData(), sizeof(Event)); - return EVENT::getEventId(event); + return event::getEventId(event); } void EventMessage::setEventId(EventId_t eventId) { From f0b13427e63ea7dfa2da89efe0894b78c1c546c9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Dec 2020 14:51:36 +0100 Subject: [PATCH 25/26] changelog update --- CHANGELOG | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 33665e60..634eb2a7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,4 +17,7 @@ a C file without issues ### Events -- makeEvent function: Now takes three input parameters instead of two and allows setting a unique ID +- makeEvent function: Now takes three input parameters instead of two and +allows setting a unique ID. Event.cpp source file removed, functions now +defined in header directly. Namespaces renamed. Functions declared `constexpr` +now From 6ee4ceeb65c53ddaefe30c2c9001d6691c032182 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Dec 2020 14:58:24 +0100 Subject: [PATCH 26/26] deleted event.cpp source file --- events/Event.cpp | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 events/Event.cpp diff --git a/events/Event.cpp b/events/Event.cpp deleted file mode 100644 index 0f76b438..00000000 --- a/events/Event.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "Event.h" - -namespace EVENT { -EventId_t getEventId(Event event) { - return (event & 0xFFFF); -} - -EventSeverity_t getSeverity(Event event) { - return ((event >> 16) & 0xFF); -} - -Event makeEvent(uint8_t subsystemId, uint8_t uniqueEventId, - EventSeverity_t eventSeverity) { - return (eventSeverity << 16) + (subsystemId * 100) + uniqueEventId; -} -}