From a9975f5aefe3698149b5f9b47e0b193007fb399a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 6 Sep 2020 15:46:49 +0200 Subject: [PATCH 01/26] added new windows udp bridge --- fsfw.mk | 16 +++ osal/windows/TcWinUdpPollingTask.cpp | 148 ++++++++++++++++++++++ osal/windows/TcWinUdpPollingTask.h | 67 ++++++++++ osal/windows/TmTcWinUdpBridge.cpp | 176 +++++++++++++++++++++++++++ osal/windows/TmTcWinUdpBridge.h | 49 ++++++++ 5 files changed, 456 insertions(+) create mode 100644 osal/windows/TcWinUdpPollingTask.cpp create mode 100644 osal/windows/TcWinUdpPollingTask.h create mode 100644 osal/windows/TmTcWinUdpBridge.cpp create mode 100644 osal/windows/TmTcWinUdpBridge.h diff --git a/fsfw.mk b/fsfw.mk index c2c6e747..c5847554 100644 --- a/fsfw.mk +++ b/fsfw.mk @@ -9,6 +9,9 @@ CXXSRC += $(wildcard $(FRAMEWORK_PATH)/controller/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/coordinates/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/datalinklayer/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/datapool/*.cpp) +CXXSRC += $(wildcard $(FRAMEWORK_PATH)/datapoolglob/*.cpp) +CXXSRC += $(wildcard $(FRAMEWORK_PATH)/datapoollocal/*.cpp) +CXXSRC += $(wildcard $(FRAMEWORK_PATH)/housekeeping/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/devicehandlers/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/events/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/events/eventmatching/*.cpp) @@ -28,12 +31,25 @@ CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/*.cpp) # select the OS ifeq ($(OS_FSFW),rtems) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/rtems/*.cpp) + else ifeq ($(OS_FSFW),linux) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/linux/*.cpp) + else ifeq ($(OS_FSFW),freeRTOS) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/FreeRTOS/*.cpp) + else ifeq ($(OS_FSFW),host) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/host/*.cpp) +ifeq ($(OS),Windows_NT) +CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/windows/*.cpp) +else +# For now, the linux UDP bridge sources needs to be included manually by upper makefile +# for host OS because we can't be sure the OS is linux. +# Following lines can be used to do this: +# CXXSRC += $(FRAMEWORK_PATH)/osal/linux/TcUnixUdpPollingTask.cpp +# CXXSRC += $(FRAMEWORK_PATH)/osal/linux/TmTcUnixUdpBridge.cpp +endif + else $(error invalid OS_FSFW specified, valid OS_FSFW are rtems, linux, freeRTOS, host) endif diff --git a/osal/windows/TcWinUdpPollingTask.cpp b/osal/windows/TcWinUdpPollingTask.cpp new file mode 100644 index 00000000..7b54bb2c --- /dev/null +++ b/osal/windows/TcWinUdpPollingTask.cpp @@ -0,0 +1,148 @@ +#include "TcWinUdpPollingTask.h" +#include "../../globalfunctions/arrayprinter.h" +#include "../../serviceinterface/ServiceInterfaceStream.h" + +#include +#include + +TcWinUdpPollingTask::TcWinUdpPollingTask(object_id_t objectId, + object_id_t tmtcUnixUdpBridge, size_t frameSize, + double timeoutSeconds): SystemObject(objectId), + tmtcBridgeId(tmtcUnixUdpBridge) { + if(frameSize > 0) { + this->frameSize = frameSize; + } + else { + this->frameSize = DEFAULT_MAX_FRAME_SIZE; + } + + // Set up reception buffer with specified frame size. + // For now, it is assumed that only one frame is held in the buffer! + receptionBuffer.reserve(this->frameSize); + receptionBuffer.resize(this->frameSize); + + if(timeoutSeconds == -1) { + receptionTimeout = DEFAULT_TIMEOUT; + } + else { + receptionTimeout = timevalOperations::toTimeval(timeoutSeconds); + } +} + +TcWinUdpPollingTask::~TcWinUdpPollingTask() {} + +ReturnValue_t TcWinUdpPollingTask::performOperation(uint8_t opCode) { + // Poll for new UDP datagrams in permanent loop. + while(true) { + //! Sender Address is cached here. + struct sockaddr_in senderAddress; + int senderAddressSize = sizeof(senderAddress); + ssize_t bytesReceived = recvfrom(serverUdpSocket, + reinterpret_cast(receptionBuffer.data()), frameSize, + receptionFlags, reinterpret_cast(&senderAddress), + &senderAddressSize); + if(bytesReceived == SOCKET_ERROR) { + // handle error + sif::error << "TcWinUdpPollingTask::performOperation: Reception" + " error." << std::endl; + handleReadError(); + continue; + } + //sif::debug << "TcWinUdpPollingTask::performOperation: " << bytesReceived + // << " bytes received" << std::endl; + + ReturnValue_t result = handleSuccessfullTcRead(bytesReceived); + if(result != HasReturnvaluesIF::RETURN_FAILED) { + + } + tmtcBridge->registerCommConnect(); + tmtcBridge->checkAndSetClientAddress(senderAddress); + } + return HasReturnvaluesIF::RETURN_OK; +} + + +ReturnValue_t TcWinUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) { + store_address_t storeId; + ReturnValue_t result = tcStore->addData(&storeId, + receptionBuffer.data(), bytesRead); + // arrayprinter::print(receptionBuffer.data(), bytesRead); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "TcSerialPollingTask::transferPusToSoftwareBus: Data " + "storage failed" << std::endl; + sif::error << "Packet size: " << bytesRead << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + + TmTcMessage message(storeId); + + result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Serial Polling: Sending message to queue failed" + << std::endl; + tcStore->deleteData(storeId); + } + return result; +} + +ReturnValue_t TcWinUdpPollingTask::initialize() { + tcStore = objectManager->get(objects::TC_STORE); + if (tcStore == nullptr) { + sif::error << "TcSerialPollingTask::initialize: TC Store uninitialized!" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + + tmtcBridge = objectManager->get(tmtcBridgeId); + if(tmtcBridge == nullptr) { + sif::error << "TcSocketPollingTask::TcSocketPollingTask: Invalid" + " TMTC bridge object!" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + + serverUdpSocket = tmtcBridge->serverSocket; + //sif::info << "TcWinUdpPollingTask::initialize: Server UDP socket " + // << serverUdpSocket << std::endl; + + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t TcWinUdpPollingTask::initializeAfterTaskCreation() { + // Initialize the destination after task creation. This ensures + // that the destination has already been set in the TMTC bridge. + targetTcDestination = tmtcBridge->getRequestQueue(); + return HasReturnvaluesIF::RETURN_OK; +} + +void TcWinUdpPollingTask::setTimeout(double timeoutSeconds) { + DWORD timeoutMs = timeoutSeconds * 1000.0; + int result = setsockopt(serverUdpSocket, SOL_SOCKET, SO_RCVTIMEO, + reinterpret_cast(&timeoutMs), sizeof(DWORD)); + if(result == -1) { + sif::error << "TcSocketPollingTask::TcSocketPollingTask: Setting " + "receive timeout failed with " << strerror(errno) << std::endl; + } +} + +void TcWinUdpPollingTask::handleReadError() { + int error = WSAGetLastError(); + switch(error) { + case(WSANOTINITIALISED): { + sif::info << "TmTcWinUdpBridge::handleReadError: WSANOTINITIALISED: " + << "WSAStartup(...) call " << "necessary" << std::endl; + break; + } + case(WSAEFAULT): { + sif::info << "TmTcWinUdpBridge::handleReadError: WSADEFAULT: " + << "Bad address " << std::endl; + break; + } + default: { + sif::info << "TmTcWinUdpBridge::handleReadError: Error code: " + << error << std::endl; + break; + } + } + // to prevent spam. + Sleep(1000); +} diff --git a/osal/windows/TcWinUdpPollingTask.h b/osal/windows/TcWinUdpPollingTask.h new file mode 100644 index 00000000..50d39d25 --- /dev/null +++ b/osal/windows/TcWinUdpPollingTask.h @@ -0,0 +1,67 @@ +#ifndef FSFW_OSAL_WINDOWS_TCSOCKETPOLLINGTASK_H_ +#define FSFW_OSAL_WINDOWS_TCSOCKETPOLLINGTASK_H_ + +#include "TmTcWinUdpBridge.h" +#include "../../objectmanager/SystemObject.h" +#include "../../tasks/ExecutableObjectIF.h" +#include "../../storagemanager/StorageManagerIF.h" + +#include + +/** + * @brief This class can be used to implement the polling of a Unix socket, + * using UDP for now. + * @details + * The task will be blocked while the specified number of bytes has not been + * received, so TC reception is handled inside a separate task. + * This class caches the IP address of the sender. It is assumed there + * is only one sender for now. + */ +class TcWinUdpPollingTask: public SystemObject, + public ExecutableObjectIF { + friend class TmTcWinUdpBridge; +public: + static constexpr size_t DEFAULT_MAX_FRAME_SIZE = 2048; + //! 0.5 default milliseconds timeout for now. + static constexpr timeval DEFAULT_TIMEOUT = {.tv_sec = 0, .tv_usec = 500}; + + TcWinUdpPollingTask(object_id_t objectId, object_id_t tmtcUnixUdpBridge, + size_t frameSize = 0, double timeoutSeconds = -1); + virtual~ TcWinUdpPollingTask(); + + /** + * Turn on optional timeout for UDP polling. In the default mode, + * the receive function will block until a packet is received. + * @param timeoutSeconds + */ + void setTimeout(double timeoutSeconds); + + virtual ReturnValue_t performOperation(uint8_t opCode) override; + virtual ReturnValue_t initialize() override; + virtual ReturnValue_t initializeAfterTaskCreation() override; + +protected: + StorageManagerIF* tcStore = nullptr; + +private: + //! TMTC bridge is cached. + object_id_t tmtcBridgeId = objects::NO_OBJECT; + TmTcWinUdpBridge* tmtcBridge = nullptr; + MessageQueueId_t targetTcDestination = MessageQueueIF::NO_QUEUE; + //! Reception flags: https://linux.die.net/man/2/recvfrom. + int receptionFlags = 0; + + //! Server socket, which is member of TMTC bridge and is assigned in + //! constructor + SOCKET serverUdpSocket = 0; + + std::vector receptionBuffer; + + size_t frameSize = 0; + timeval receptionTimeout; + + ReturnValue_t handleSuccessfullTcRead(size_t bytesRead); + void handleReadError(); +}; + +#endif /* FRAMEWORK_OSAL_LINUX_TCSOCKETPOLLINGTASK_H_ */ diff --git a/osal/windows/TmTcWinUdpBridge.cpp b/osal/windows/TmTcWinUdpBridge.cpp new file mode 100644 index 00000000..7e283c2a --- /dev/null +++ b/osal/windows/TmTcWinUdpBridge.cpp @@ -0,0 +1,176 @@ +#include +#include "TmTcWinUdpBridge.h" + +TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, + object_id_t tcDestination, object_id_t tmStoreId, object_id_t tcStoreId, + uint16_t serverPort, uint16_t clientPort): + TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { + mutex = MutexFactory::instance()->createMutex(); + + // Initiates Winsock DLL. + WSAData wsaData; + WORD wVersionRequested = MAKEWORD(2, 2); + int err = WSAStartup(wVersionRequested, &wsaData); + if (err != 0) { + /* Tell the user that we could not find a usable */ + /* Winsock DLL. */ + sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge:" + "WSAStartup failed with error: " << err << std::endl; + return; + } + + uint16_t setServerPort = DEFAULT_UDP_SERVER_PORT; + if(serverPort != 0xFFFF) { + setServerPort = serverPort; + } + + uint16_t setClientPort = DEFAULT_UDP_CLIENT_PORT; + if(clientPort != 0xFFFF) { + setClientPort = clientPort; + } + + // Set up UDP socket: https://man7.org/linux/man-pages/man7/ip.7.html + //clientSocket = socket(AF_INET, SOCK_DGRAM, 0); + serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if(serverSocket == INVALID_SOCKET) { + sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: Could not open" + " UDP socket!" << std::endl; + handleSocketError(); + return; + } + + serverAddress.sin_family = AF_INET; + + // Accept packets from any interface. (potentially insecure). + serverAddress.sin_addr.s_addr = htonl(INADDR_ANY); + serverAddress.sin_port = htons(setServerPort); + serverAddressLen = sizeof(serverAddress); + setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, + reinterpret_cast(&serverSocketOptions), + sizeof(serverSocketOptions)); + + clientAddress.sin_family = AF_INET; + clientAddress.sin_addr.s_addr = htonl(INADDR_ANY); + clientAddress.sin_port = htons(setClientPort); + clientAddressLen = sizeof(clientAddress); + + int result = bind(serverSocket, + reinterpret_cast(&serverAddress), + serverAddressLen); + if(result != 0) { + sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: Could not bind " + "local port " << setServerPort << " to server socket!" + << std::endl; + handleBindError(); + } +} + +TmTcWinUdpBridge::~TmTcWinUdpBridge() { + WSACleanup(); +} + +ReturnValue_t TmTcWinUdpBridge::sendTm(const uint8_t *data, size_t dataLen) { + int flags = 0; + + //clientAddress.sin_addr.s_addr = htons(INADDR_ANY); + //clientAddressLen = sizeof(serverAddress); + +// char ipAddress [15]; +// sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, +// &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; + + ssize_t bytesSent = sendto(serverSocket, + reinterpret_cast(data), dataLen, flags, + reinterpret_cast(&clientAddress), clientAddressLen); + if(bytesSent == SOCKET_ERROR) { + sif::error << "TmTcWinUdpBridge::sendTm: Send operation failed." + << std::endl; + handleSendError(); + } +// sif::debug << "TmTcUnixUdpBridge::sendTm: " << bytesSent << " bytes were" +// " sent." << std::endl; + return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; +} + +void TmTcWinUdpBridge::checkAndSetClientAddress(sockaddr_in newAddress) { + MutexHelper lock(mutex, MutexIF::TimeoutType::WAITING, 10); + +// char ipAddress [15]; +// sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, +// &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; + + // Set new IP address if it has changed. + if(clientAddress.sin_addr.s_addr != newAddress.sin_addr.s_addr) { + clientAddress.sin_addr.s_addr = newAddress.sin_addr.s_addr; + clientAddressLen = sizeof(clientAddress); + } +} + +void TmTcWinUdpBridge::handleSocketError() { + int errCode = WSAGetLastError(); + switch(errCode) { + case(WSANOTINITIALISED): { + sif::info << "TmTcWinUdpBridge::handleSocketError: WSANOTINITIALISED: " + << "WSAStartup(...) call " << "necessary" << std::endl; + break; + } + default: { + /* + https://docs.microsoft.com/en-us/windows/win32/winsock/ + windows-sockets-error-codes-2 + */ + sif::info << "TmTcWinUdpBridge::handleSocketError: Error code: " + << errCode << std::endl; + break; + } + } +} + +void TmTcWinUdpBridge::handleBindError() { + int errCode = WSAGetLastError(); + switch(errCode) { + case(WSANOTINITIALISED): { + sif::info << "TmTcWinUdpBridge::handleBindError: WSANOTINITIALISED: " + << "WSAStartup(...) call " << "necessary" << std::endl; + break; + } + default: { + /* + https://docs.microsoft.com/en-us/windows/win32/winsock/ + windows-sockets-error-codes-2 + */ + sif::info << "TmTcWinUdpBridge::handleBindError: Error code: " + << errCode << std::endl; + break; + } + } +} + +void TmTcWinUdpBridge::handleSendError() { + int errCode = WSAGetLastError(); + switch(errCode) { + case(WSANOTINITIALISED): { + sif::info << "TmTcWinUdpBridge::handleSendError: WSANOTINITIALISED: " + << "WSAStartup(...) call " << "necessary" << std::endl; + break; + } + case(WSAEADDRNOTAVAIL): { + sif::info << "TmTcWinUdpBridge::handleReadError: WSAEADDRNOTAVAIL: " + << "Check target address. " << std::endl; + break; + } + default: { + /* + https://docs.microsoft.com/en-us/windows/win32/winsock/ + windows-sockets-error-codes-2 + */ + sif::info << "TmTcWinUdpBridge::handleSendError: Error code: " + << errCode << std::endl; + break; + } + } +} + diff --git a/osal/windows/TmTcWinUdpBridge.h b/osal/windows/TmTcWinUdpBridge.h new file mode 100644 index 00000000..8188039c --- /dev/null +++ b/osal/windows/TmTcWinUdpBridge.h @@ -0,0 +1,49 @@ +#ifndef FSFW_OSAL_WINDOWS_TMTCWINUDPBRIDGE_H_ +#define FSFW_OSAL_WINDOWS_TMTCWINUDPBRIDGE_H_ + +#include "../../tmtcservices/TmTcBridge.h" + +#include +#include + +class TmTcWinUdpBridge: public TmTcBridge { + friend class TcWinUdpPollingTask; +public: + // The ports chosen here should not be used by any other process. + static constexpr uint16_t DEFAULT_UDP_SERVER_PORT = 7301; + static constexpr uint16_t DEFAULT_UDP_CLIENT_PORT = 7302; + + TmTcWinUdpBridge(object_id_t objectId, object_id_t tcDestination, + object_id_t tmStoreId, object_id_t tcStoreId, + uint16_t serverPort = 0xFFFF,uint16_t clientPort = 0xFFFF); + virtual~ TmTcWinUdpBridge(); + + void checkAndSetClientAddress(sockaddr_in clientAddress); + +protected: + virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) override; + +private: + SOCKET serverSocket = 0; + + const int serverSocketOptions = 0; + + struct sockaddr_in clientAddress; + int clientAddressLen = 0; + + struct sockaddr_in serverAddress; + int serverAddressLen = 0; + + //! Access to the client address is mutex protected as it is set + //! by another task. + MutexIF* mutex; + + void handleSocketError(); + void handleBindError(); + void handleSendError(); +}; + + + +#endif /* FSFW_OSAL_HOST_TMTCWINUDPBRIDGE_H_ */ + From 1635f16bc03d13edb09144eb5ed5e4575cbe88ac Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 15:26:33 +0200 Subject: [PATCH 02/26] removed changes from datapool separation --- fsfw.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/fsfw.mk b/fsfw.mk index c5847554..bf95727c 100644 --- a/fsfw.mk +++ b/fsfw.mk @@ -9,8 +9,6 @@ CXXSRC += $(wildcard $(FRAMEWORK_PATH)/controller/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/coordinates/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/datalinklayer/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/datapool/*.cpp) -CXXSRC += $(wildcard $(FRAMEWORK_PATH)/datapoolglob/*.cpp) -CXXSRC += $(wildcard $(FRAMEWORK_PATH)/datapoollocal/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/housekeeping/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/devicehandlers/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/events/*.cpp) From 72f924813d337bc60d415b2a641afdf132a57f80 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 15:36:54 +0200 Subject: [PATCH 03/26] .mk fix --- fsfw.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/fsfw.mk b/fsfw.mk index bf95727c..3639717b 100644 --- a/fsfw.mk +++ b/fsfw.mk @@ -9,7 +9,6 @@ CXXSRC += $(wildcard $(FRAMEWORK_PATH)/controller/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/coordinates/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/datalinklayer/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/datapool/*.cpp) -CXXSRC += $(wildcard $(FRAMEWORK_PATH)/housekeeping/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/devicehandlers/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/events/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/events/eventmatching/*.cpp) From 482b77ff051a395210d2bd14a9f901b6222215c8 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 20 Oct 2020 17:38:41 +0200 Subject: [PATCH 04/26] added defaultcfg config folder --- defaultcfg/FSFWConfig.h | 41 +++ defaultcfg/README.md | 6 + defaultcfg/config.mk | 17 ++ defaultcfg/config/FSFWConfig.h | 41 +++ defaultcfg/config/OBSWConfig.h | 14 + .../config/devices/logicalAddresses.cpp | 5 + defaultcfg/config/devices/logicalAddresses.h | 18 ++ .../config/devices/powerSwitcherList.cpp | 4 + defaultcfg/config/devices/powerSwitcherList.h | 12 + defaultcfg/config/events/subsystemIdRanges.h | 18 ++ defaultcfg/config/ipc/missionMessageTypes.cpp | 11 + defaultcfg/config/ipc/missionMessageTypes.h | 21 ++ defaultcfg/config/objects/Factory.cpp | 57 ++++ defaultcfg/config/objects/Factory.h | 20 ++ defaultcfg/config/objects/systemObjectList.h | 138 +++++++++ .../config/objects/translateObjects.cpp | 271 ++++++++++++++++++ defaultcfg/config/objects/translateObjects.h | 9 + .../PollingSequenceFactory.cpp | 23 ++ .../pollingsequence/PollingSequenceFactory.h | 32 +++ defaultcfg/config/returnvalues/classIds.h | 16 ++ defaultcfg/config/tmtc/apid.h | 18 ++ defaultcfg/config/tmtc/pusIds.h | 23 ++ defaultcfg/config/version.h | 9 + defaultcfg/version.h | 11 + 24 files changed, 835 insertions(+) create mode 100644 defaultcfg/FSFWConfig.h create mode 100644 defaultcfg/README.md create mode 100644 defaultcfg/config.mk create mode 100644 defaultcfg/config/FSFWConfig.h create mode 100644 defaultcfg/config/OBSWConfig.h create mode 100644 defaultcfg/config/devices/logicalAddresses.cpp create mode 100644 defaultcfg/config/devices/logicalAddresses.h create mode 100644 defaultcfg/config/devices/powerSwitcherList.cpp create mode 100644 defaultcfg/config/devices/powerSwitcherList.h create mode 100644 defaultcfg/config/events/subsystemIdRanges.h create mode 100644 defaultcfg/config/ipc/missionMessageTypes.cpp create mode 100644 defaultcfg/config/ipc/missionMessageTypes.h create mode 100644 defaultcfg/config/objects/Factory.cpp create mode 100644 defaultcfg/config/objects/Factory.h create mode 100644 defaultcfg/config/objects/systemObjectList.h create mode 100644 defaultcfg/config/objects/translateObjects.cpp create mode 100644 defaultcfg/config/objects/translateObjects.h create mode 100644 defaultcfg/config/pollingsequence/PollingSequenceFactory.cpp create mode 100644 defaultcfg/config/pollingsequence/PollingSequenceFactory.h create mode 100644 defaultcfg/config/returnvalues/classIds.h create mode 100644 defaultcfg/config/tmtc/apid.h create mode 100644 defaultcfg/config/tmtc/pusIds.h create mode 100644 defaultcfg/config/version.h create mode 100644 defaultcfg/version.h diff --git a/defaultcfg/FSFWConfig.h b/defaultcfg/FSFWConfig.h new file mode 100644 index 00000000..2001f306 --- /dev/null +++ b/defaultcfg/FSFWConfig.h @@ -0,0 +1,41 @@ +#ifndef CONFIG_FSFWCONFIG_H_ +#define CONFIG_FSFWCONFIG_H_ + +#include "version.h" + +//! Used to determine whether C++ ostreams are used +//! Those can lead to code bloat. +#define FSFW_CPP_OSTREAM_ENABLED 1 + +//! Reduced printout to further decrese code size +//! Be careful, this also turns off most diagnostic prinouts! +#define FSFW_REDUCED_PRINTOUT 0 + +//! Can be used to enable debugging printouts for developing the FSFW +#define FSFW_DEBUGGING 0 + +//! Defines the FIFO depth of each commanding service base which +//! also determines how many commands a CSB service can handle in one cycle +//! simulataneously. This will increase the required RAM for +//! each CSB service ! +#define FSFW_CSB_FIFO_DEPTH 6 + +//! If -DDEBUG is supplied in the build defines, there will be +//! additional output which requires the translation files translateObjects +//! and translateEvents (and their compiles source files) +#ifdef DEBUG +#define FSFW_DEBUG_OUTPUT 1 +//! Specify whether info events are printed too. +#define FSFW_DEBUG_INFO 1 +#include +#include +#else +#define FSFW_DEBUG_OUTPUT 0 +#endif + +//! When using the newlib nano library, C99 support for stdio facilities +//! will not be provided. This define should be set to 1 if this is the case. +#define FSFW_NO_C99_IO 1 + + +#endif /* CONFIG_FSFWCONFIG_H_ */ diff --git a/defaultcfg/README.md b/defaultcfg/README.md new file mode 100644 index 00000000..8446cda4 --- /dev/null +++ b/defaultcfg/README.md @@ -0,0 +1,6 @@ +# How to setup configuration folder for FSFW + +It is recommended to copy the content of the defaultcfg folder +into a config folder which is in the same directory as the Flight +Software Framework submodule. After that, the config.mk folder should be +included by the primary Makefile with CURRENTPATH set correctly. diff --git a/defaultcfg/config.mk b/defaultcfg/config.mk new file mode 100644 index 00000000..fcf3b799 --- /dev/null +++ b/defaultcfg/config.mk @@ -0,0 +1,17 @@ +CXXSRC += $(wildcard $(CURRENTPATH)/config/ipc/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/config/objects/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/config/pollingsequence/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/config/events/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/config/tmtc/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/config/devices/*.cpp) + +INCLUDES += $(CURRENTPATH) +INCLUDES += $(CURRENTPATH)/config/ +INCLUDES += $(CURRENTPATH)/config/objects +INCLUDES += $(CURRENTPATH)/config/returnvalues +INCLUDES += $(CURRENTPATH)/config/tmtc +INCLUDES += $(CURRENTPATH)/config/events +INCLUDES += $(CURRENTPATH)/config/devices +INCLUDES += $(CURRENTPATH)/config/pollingsequence +INCLUDES += $(CURRENTPATH)/config/ipc +INCLUDES += $(CURRENTPATH)/config/ diff --git a/defaultcfg/config/FSFWConfig.h b/defaultcfg/config/FSFWConfig.h new file mode 100644 index 00000000..2001f306 --- /dev/null +++ b/defaultcfg/config/FSFWConfig.h @@ -0,0 +1,41 @@ +#ifndef CONFIG_FSFWCONFIG_H_ +#define CONFIG_FSFWCONFIG_H_ + +#include "version.h" + +//! Used to determine whether C++ ostreams are used +//! Those can lead to code bloat. +#define FSFW_CPP_OSTREAM_ENABLED 1 + +//! Reduced printout to further decrese code size +//! Be careful, this also turns off most diagnostic prinouts! +#define FSFW_REDUCED_PRINTOUT 0 + +//! Can be used to enable debugging printouts for developing the FSFW +#define FSFW_DEBUGGING 0 + +//! Defines the FIFO depth of each commanding service base which +//! also determines how many commands a CSB service can handle in one cycle +//! simulataneously. This will increase the required RAM for +//! each CSB service ! +#define FSFW_CSB_FIFO_DEPTH 6 + +//! If -DDEBUG is supplied in the build defines, there will be +//! additional output which requires the translation files translateObjects +//! and translateEvents (and their compiles source files) +#ifdef DEBUG +#define FSFW_DEBUG_OUTPUT 1 +//! Specify whether info events are printed too. +#define FSFW_DEBUG_INFO 1 +#include +#include +#else +#define FSFW_DEBUG_OUTPUT 0 +#endif + +//! When using the newlib nano library, C99 support for stdio facilities +//! will not be provided. This define should be set to 1 if this is the case. +#define FSFW_NO_C99_IO 1 + + +#endif /* CONFIG_FSFWCONFIG_H_ */ diff --git a/defaultcfg/config/OBSWConfig.h b/defaultcfg/config/OBSWConfig.h new file mode 100644 index 00000000..d186da7d --- /dev/null +++ b/defaultcfg/config/OBSWConfig.h @@ -0,0 +1,14 @@ +#ifndef CONFIG_OBSWCONFIG_H_ +#define CONFIG_OBSWCONFIG_H_ + +#ifdef __cplusplus +namespace config { +#endif + +/* Add mission configuration flags here */ + +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_OBSWCONFIG_H_ */ diff --git a/defaultcfg/config/devices/logicalAddresses.cpp b/defaultcfg/config/devices/logicalAddresses.cpp new file mode 100644 index 00000000..c7ce314d --- /dev/null +++ b/defaultcfg/config/devices/logicalAddresses.cpp @@ -0,0 +1,5 @@ +#include "logicalAddresses.h" + + + + diff --git a/defaultcfg/config/devices/logicalAddresses.h b/defaultcfg/config/devices/logicalAddresses.h new file mode 100644 index 00000000..174fa788 --- /dev/null +++ b/defaultcfg/config/devices/logicalAddresses.h @@ -0,0 +1,18 @@ +#ifndef CONFIG_DEVICES_LOGICALADDRESSES_H_ +#define CONFIG_DEVICES_LOGICALADDRESSES_H_ + +#include +#include +#include + +/** + * Can be used for addresses for physical devices like I2C adresses. + */ +namespace addresses { + /* Logical addresses have uint32_t datatype */ + enum logicalAddresses: address_t { + }; +} + + +#endif /* CONFIG_DEVICES_LOGICALADDRESSES_H_ */ diff --git a/defaultcfg/config/devices/powerSwitcherList.cpp b/defaultcfg/config/devices/powerSwitcherList.cpp new file mode 100644 index 00000000..343f78d0 --- /dev/null +++ b/defaultcfg/config/devices/powerSwitcherList.cpp @@ -0,0 +1,4 @@ +#include "powerSwitcherList.h" + + + diff --git a/defaultcfg/config/devices/powerSwitcherList.h b/defaultcfg/config/devices/powerSwitcherList.h new file mode 100644 index 00000000..86ddea57 --- /dev/null +++ b/defaultcfg/config/devices/powerSwitcherList.h @@ -0,0 +1,12 @@ +#ifndef CONFIG_DEVICES_POWERSWITCHERLIST_H_ +#define CONFIG_DEVICES_POWERSWITCHERLIST_H_ + +namespace switches { + /* Switches are uint8_t datatype and go from 0 to 255 */ + enum switcherList { + }; + +} + + +#endif /* CONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/defaultcfg/config/events/subsystemIdRanges.h b/defaultcfg/config/events/subsystemIdRanges.h new file mode 100644 index 00000000..24eee819 --- /dev/null +++ b/defaultcfg/config/events/subsystemIdRanges.h @@ -0,0 +1,18 @@ +#ifndef CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ +#define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ + +#include +#include + +/** + * @brief Custom subsystem IDs can be added here + * @details + * Subsystem IDs are used to create unique events. + */ +namespace SUBSYSTEM_ID { +enum: uint8_t { + SUBSYSTEM_ID_START = FW_SUBSYSTEM_ID_RANGE, +}; +} + +#endif /* CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ */ diff --git a/defaultcfg/config/ipc/missionMessageTypes.cpp b/defaultcfg/config/ipc/missionMessageTypes.cpp new file mode 100644 index 00000000..e2edbf9c --- /dev/null +++ b/defaultcfg/config/ipc/missionMessageTypes.cpp @@ -0,0 +1,11 @@ +#include +#include + +void messagetypes::clearMissionMessage(CommandMessage* message) { + switch(message->getMessageType()) { + default: + break; + } +} + + diff --git a/defaultcfg/config/ipc/missionMessageTypes.h b/defaultcfg/config/ipc/missionMessageTypes.h new file mode 100644 index 00000000..8b2e2fcc --- /dev/null +++ b/defaultcfg/config/ipc/missionMessageTypes.h @@ -0,0 +1,21 @@ +#ifndef CONFIG_IPC_MISSIONMESSAGETYPES_H_ +#define CONFIG_IPC_MISSIONMESSAGETYPES_H_ + +#include +#include + +/** + * Custom command messages are specified here. + * Most messages needed to use FSFW are already located in + * + * @param message Generic Command Message + */ +namespace messagetypes { +enum CustomMessageTypes { + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT +}; + +void clearMissionMessage(CommandMessage* message); +} + +#endif /* CONFIG_IPC_MISSIONMESSAGETYPES_H_ */ diff --git a/defaultcfg/config/objects/Factory.cpp b/defaultcfg/config/objects/Factory.cpp new file mode 100644 index 00000000..ea187a5e --- /dev/null +++ b/defaultcfg/config/objects/Factory.cpp @@ -0,0 +1,57 @@ +#include "Factory.h" + +/* Config */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +#include + + +/** + * 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 nterface 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() { + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; + + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + + 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; + + TmPacketStored::timeStamperId = objects::PUS_TIME; + TmFunnel::downlinkDestination = objects::NO_OBJECT; +} + diff --git a/defaultcfg/config/objects/Factory.h b/defaultcfg/config/objects/Factory.h new file mode 100644 index 00000000..8b99ae99 --- /dev/null +++ b/defaultcfg/config/objects/Factory.h @@ -0,0 +1,20 @@ +#ifndef FACTORY_H_ +#define FACTORY_H_ + +#include +#include + +namespace Factory { + size_t calculateStorage(uint8_t numberOfPools, uint16_t* numberOfElements, + uint16_t* sizeOfElements); + /** + * @brief Creates all SystemObject elements which are persistent + * during execution. + */ + void produce(); + void setStaticFrameworkObjectIds(); + +} + + +#endif /* FACTORY_H_ */ diff --git a/defaultcfg/config/objects/systemObjectList.h b/defaultcfg/config/objects/systemObjectList.h new file mode 100644 index 00000000..2448efbd --- /dev/null +++ b/defaultcfg/config/objects/systemObjectList.h @@ -0,0 +1,138 @@ +#ifndef CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ +#define CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ + +#include + +// The objects will be instantiated in the ID order +namespace objects { + enum sourceObjects: uint32_t { + /* First Byte 0x50-0x52 reserved for PUS Services **/ + CCSDS_PACKET_DISTRIBUTOR = 0x50000100, + PUS_PACKET_DISTRIBUTOR = 0x50000200, + /* UDP ID must come after CCSDS Distributor **/ + UDP_TMTC_BRIDGE = 0x50000300, + EMAC_POLLING_TASK = 0x50000400, + SERIAL_TMTC_BRIDGE = 0x50000500, + SERIAL_RING_BUFFER = 0x50000550, + SERIAL_POLLING_TASK = 0x50000600, + + PUS_SERVICE_6_MEM_MGMT = 0x51000500, + PUS_SERVICE_20_PARAM_MGMT = 0x51002000, + PUS_SERVICE_23_FILE_MGMT = 0x51002300, + PUS_SERVICE_201_HEALTH = 0x51020100, + + PUS_TIME = 0x52000001, + TM_FUNNEL = 0x52000002, + FREERTOS_TASK_MONITOR = 0x53000003, + + CORE_CONTROLLER = 0x40001000, + SYSTEM_STATE_TASK = 0x40001005, + THERMAL_CONTROLLER = 0x40002000, + RS485_CONTROLLER = 0x40005000, + + /* 0x44 ('D') for Device Handlers **/ + /* Second Byte: ComIF -> 0x00: UART,0x10 SPI,0x20: I2C,30: GPIO,40: PWM */ + /* Third Byte: Device ID */ + PCDU_HANDLER = 0x44003200, + GPS0_HANDLER = 0x44101F00, + GPS1_HANDLER = 0x44202000, + + DLR_PVCH = 0x44104000, + GYRO1 = 0x44105000, + DLR_IRAS = 0x44106000, + + /* fourth byte decoder output ID */ + + // Devices connected to decoder 1 + SPI_Test_PT1000 = 0x44115400, + SPI_Test_Gyro = 0x44115500, + PT1000_Syrlinks_DEC1_O1 = 0x44115401, + PT1000_Camera_DEC1_O2 = 0x44115402, + PT1000_SuS1_DEC1_O3 = 0x44115404, + PT1000_SuS2_DEC1_O4 = 0x44115405, + PT1000_SuS3_DEC1_O5 = 0x44115406, + PT1000_PVHC_DEC1_O6 = 0x44115407, + + // Devices connected to decoder 2 + PT1000_CCSDS1_DEC2 = 0x44125401, + PT1000_MGT1_DEC2 = 0x44125403, + PT1000_SuS4_DEC2 = 0x44125404, + PT1000_SuS5_DEC2 = 0x44125405, + PT1000_SuS6_DEC2 = 0x44125406, + PT1000_PVCH_DEC2 = 0x44125407, + SuS_ADC1_DEC2 = 0x44020108, + + // Devices connected to decoder 3 + PT1000_Iridium_DEC3 = 0x44130301, + PT1000_CCSDS2_DEC3 = 0x44130302, + PT1000_SuS7_DEC3 = 0x44130305, + PT1000_SuS8_DEC3 = 0x44130306, + PT1000_PVCH_DEC3 = 0x44130307, + GYRO2 = 0x44130308, + + // Devices connected to decoder 4 + PT1000_PLOC_DEC4 = 0x44145401, + PT1000_SuS9_DEC4 = 0x44145404, + PT1000_SuS10_DEC4 = 0x44145405, + PT1000_PVHC_DEC4 = 0x44145406, + SuS_ADC_DEC4 = 0x44145407, + + /* 0x49 ('I') for Communication Interfaces **/ + DUMMY_ECHO_COM_IF = 0x4900AFFE, + DUMMY_GPS_COM_IF = 0x49001F00, + RS232_DEVICE_COM_IF = 0x49005200, + I2C_DEVICE_COM_IF = 0x49005300, + GPIO_DEVICE_COM_IF = 0x49005400, + SPI_DEVICE_COM_IF = 0x49005600, + //SPI_POLLING_TASK = 0x49005410, + + /* 0x4d ('M') for Memory Handlers **/ + SD_CARD_HANDLER = 0x4D0073AD, + FRAM_HANDLER = 0x4D008000, + SOFTWARE_IMAGE_HANDLER = 0x4D009000, + + /* Board Specific */ + AT91_I2C_TEST_TASK = 0x12345678, + AT91_UART0_TEST_TASK = 0x87654321, + AT91_UART2_TEST_TASK = 0x000123336, + AT91_SPI_TEST_TASK = 0x66666666, + STM32_TEST_TASK = 0x77777777, + LED_TASK = 0x12345777, + + /* Test Task */ + ARDUINO_0 = 0x01010100, + ARDUINO_1 = 0x01010101, + ARDUINO_2 = 0x01010102, + ARDUINO_3 = 0x01010103, + ARDUINO_4 = 0x01010104, + TEST_TASK = 0x42694269, + DUMMY_HANDLER = 0x4400AFFE, + TC_INJECTOR = 0x99000001 + }; +} + +#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ + + +/** + ▄ ▄ + ▌▒█ ▄▀▒▌ + ▌▒▒█ ▄▀▒▒▒▐ + ▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐ + ▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐ + ▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌ + ▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌ + ▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐ + ▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌ + ▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌ + ▌▒▀▐▄█▄█▌▄░▀▒▒░░░░░░░░░░▒▒▒▐ + ▐▒▒▐▀▐▀▒░▄▄▒▄▒▒▒▒▒▒░▒░▒░▒▒▒▒▌ + ▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▐ + ▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒░▒░▒░▒░▒▒▒▌ + ▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▄▒▒▐ + ▀▄▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▄▒▒▒▒▌ + ▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀ + ▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀ + ▒▒▒▒▒▒▒▒▒▒▀▀ +*/ + diff --git a/defaultcfg/config/objects/translateObjects.cpp b/defaultcfg/config/objects/translateObjects.cpp new file mode 100644 index 00000000..73cd02bf --- /dev/null +++ b/defaultcfg/config/objects/translateObjects.cpp @@ -0,0 +1,271 @@ +/** + * @brief Auto-generated object translation file. Contains 86 translations. + * Generated on: 2020-08-25 00:57:14 + **/ +#include "translateObjects.h" + +const char *AT91_UART2_TEST_TASK_STRING = "AT91_UART2_TEST_TASK"; +const char *ARDUINO_0_STRING = "ARDUINO_0"; +const char *ARDUINO_1_STRING = "ARDUINO_1"; +const char *ARDUINO_2_STRING = "ARDUINO_2"; +const char *ARDUINO_3_STRING = "ARDUINO_3"; +const char *ARDUINO_4_STRING = "ARDUINO_4"; +const char *AT91_I2C_TEST_TASK_STRING = "AT91_I2C_TEST_TASK"; +const char *LED_TASK_STRING = "LED_TASK"; +const char *TEST_TASK_STRING = "TEST_TASK"; +const char *PCDU_HANDLER_STRING = "PCDU_HANDLER"; +const char *DUMMY_HANDLER_STRING = "DUMMY_HANDLER"; +const char *SuS_ADC1_DEC2_STRING = "SuS_ADC1_DEC2"; +const char *GPS0_HANDLER_STRING = "GPS0_HANDLER"; +const char *DLR_PVCH_STRING = "DLR_PVCH"; +const char *GYRO1_STRING = "GYRO1"; +const char *DLR_IRAS_STRING = "DLR_IRAS"; +const char *SPI_Test_PT1000_STRING = "SPI_Test_PT1000"; +const char *PT1000_Syrlinks_DEC1_O1_STRING = "PT1000_Syrlinks_DEC1_O1"; +const char *PT1000_Camera_DEC1_O2_STRING = "PT1000_Camera_DEC1_O2"; +const char *PT1000_SuS1_DEC1_O3_STRING = "PT1000_SuS1_DEC1_O3"; +const char *PT1000_SuS2_DEC1_O4_STRING = "PT1000_SuS2_DEC1_O4"; +const char *PT1000_SuS3_DEC1_O5_STRING = "PT1000_SuS3_DEC1_O5"; +const char *PT1000_PVHC_DEC1_O6_STRING = "PT1000_PVHC_DEC1_O6"; +const char *SPI_Test_Gyro_STRING = "SPI_Test_Gyro"; +const char *PT1000_CCSDS1_DEC2_STRING = "PT1000_CCSDS1_DEC2"; +const char *PT1000_MGT1_DEC2_STRING = "PT1000_MGT1_DEC2"; +const char *PT1000_SuS4_DEC2_STRING = "PT1000_SuS4_DEC2"; +const char *PT1000_SuS5_DEC2_STRING = "PT1000_SuS5_DEC2"; +const char *PT1000_SuS6_DEC2_STRING = "PT1000_SuS6_DEC2"; +const char *PT1000_PVCH_DEC2_STRING = "PT1000_PVCH_DEC2"; +const char *PT1000_Iridium_DEC3_STRING = "PT1000_Iridium_DEC3"; +const char *PT1000_CCSDS2_DEC3_STRING = "PT1000_CCSDS2_DEC3"; +const char *PT1000_SuS7_DEC3_STRING = "PT1000_SuS7_DEC3"; +const char *PT1000_SuS8_DEC3_STRING = "PT1000_SuS8_DEC3"; +const char *PT1000_PVCH_DEC3_STRING = "PT1000_PVCH_DEC3"; +const char *GYRO2_STRING = "GYRO2"; +const char *PT1000_PLOC_DEC4_STRING = "PT1000_PLOC_DEC4"; +const char *PT1000_SuS9_DEC4_STRING = "PT1000_SuS9_DEC4"; +const char *PT1000_SuS10_DEC4_STRING = "PT1000_SuS10_DEC4"; +const char *PT1000_PVHC_DEC4_STRING = "PT1000_PVHC_DEC4"; +const char *SuS_ADC_DEC4_STRING = "SuS_ADC_DEC4"; +const char *GPS1_HANDLER_STRING = "GPS1_HANDLER"; +const char *DUMMY_GPS_COM_IF_STRING = "DUMMY_GPS_COM_IF"; +const char *RS232_DEVICE_COM_IF_STRING = "RS232_DEVICE_COM_IF"; +const char *I2C_DEVICE_COM_IF_STRING = "I2C_DEVICE_COM_IF"; +const char *GPIO_DEVICE_COM_IF_STRING = "GPIO_DEVICE_COM_IF"; +const char *SPI_POLLING_TASK_STRING = "SPI_POLLING_TASK"; +const char *SPI_DEVICE_COM_IF_STRING = "SPI_DEVICE_COM_IF"; +const char *DUMMY_ECHO_COM_IF_STRING = "DUMMY_ECHO_COM_IF"; +const char *SD_CARD_HANDLER_STRING = "SD_CARD_HANDLER"; +const char *CCSDS_PACKET_DISTRIBUTOR_STRING = "CCSDS_PACKET_DISTRIBUTOR"; +const char *PUS_PACKET_DISTRIBUTOR_STRING = "PUS_PACKET_DISTRIBUTOR"; +const char *UDP_TMTC_BRIDGE_STRING = "UDP_TMTC_BRIDGE"; +const char *EMAC_POLLING_TASK_STRING = "EMAC_POLLING_TASK"; +const char *SERIAL_TMTC_BRIDGE_STRING = "SERIAL_TMTC_BRIDGE"; +const char *SERIAL_RING_BUFFER_STRING = "SERIAL_RING_BUFFER"; +const char *SERIAL_POLLING_TASK_STRING = "SERIAL_POLLING_TASK"; +const char *PUS_SERVICE_1_STRING = "PUS_SERVICE_1"; +const char *PUS_SERVICE_2_STRING = "PUS_SERVICE_2"; +const char *PUS_SERVICE_3_STRING = "PUS_SERVICE_3"; +const char *PUS_SERVICE_3_PSB_STRING = "PUS_SERVICE_3_PSB"; +const char *PUS_SERVICE_5_STRING = "PUS_SERVICE_5"; +const char *PUS_SERVICE_6_STRING = "PUS_SERVICE_6"; +const char *PUS_SERVICE_8_STRING = "PUS_SERVICE_8"; +const char *PUS_SERVICE_9_STRING = "PUS_SERVICE_9"; +const char *PUS_SERVICE_17_STRING = "PUS_SERVICE_17"; +const char *PUS_SERVICE_20_STRING = "PUS_SERVICE_20"; +const char *PUS_SERVICE_23_STRING = "PUS_SERVICE_23"; +const char *PUS_SERVICE_200_STRING = "PUS_SERVICE_200"; +const char *PUS_SERVICE_201_STRING = "PUS_SERVICE_201"; +const char *PUS_TIME_STRING = "PUS_TIME"; +const char *PUS_FUNNEL_STRING = "PUS_FUNNEL"; +const char *FREERTOS_TASK_MONITOR_STRING = "FREERTOS_TASK_MONITOR"; +const char *HEALTH_TABLE_STRING = "HEALTH_TABLE"; +const char *MODE_STORE_STRING = "MODE_STORE"; +const char *EVENT_MANAGER_STRING = "EVENT_MANAGER"; +const char *INTERNAL_ERROR_REPORTER_STRING = "INTERNAL_ERROR_REPORTER"; +const char *TC_STORE_STRING = "TC_STORE"; +const char *TM_STORE_STRING = "TM_STORE"; +const char *IPC_STORE_STRING = "IPC_STORE"; +const char *AT91_SPI_TEST_TASK_STRING = "AT91_SPI_TEST_TASK"; +const char *STM32_TEST_TASK_STRING = "STM32_TEST_TASK"; +const char *AT91_UART0_TEST_TASK_STRING = "AT91_UART0_TEST_TASK"; +const char *TC_INJECTOR_STRING = "TC_INJECTOR"; +const char *NO_OBJECT_STRING = "NO_OBJECT"; + +const char* translateObject(object_id_t object){ + switch((object&0xFFFFFFFF)){ + case 0x000123336: + return AT91_UART2_TEST_TASK_STRING; + case 0x01010100: + return ARDUINO_0_STRING; + case 0x01010101: + return ARDUINO_1_STRING; + case 0x01010102: + return ARDUINO_2_STRING; + case 0x01010103: + return ARDUINO_3_STRING; + case 0x01010104: + return ARDUINO_4_STRING; + case 0x12345678: + return AT91_I2C_TEST_TASK_STRING; + case 0x12345777: + return LED_TASK_STRING; + case 0x42694269: + return TEST_TASK_STRING; + case 0x44003200: + return PCDU_HANDLER_STRING; + case 0x4400AFFE: + return DUMMY_HANDLER_STRING; + case 0x44020108: + return SuS_ADC1_DEC2_STRING; + case 0x44101F00: + return GPS0_HANDLER_STRING; + case 0x44104000: + return DLR_PVCH_STRING; + case 0x44105000: + return GYRO1_STRING; + case 0x44106000: + return DLR_IRAS_STRING; + case 0x44115400: + return SPI_Test_PT1000_STRING; + case 0x44115401: + return PT1000_Syrlinks_DEC1_O1_STRING; + case 0x44115402: + return PT1000_Camera_DEC1_O2_STRING; + case 0x44115404: + return PT1000_SuS1_DEC1_O3_STRING; + case 0x44115405: + return PT1000_SuS2_DEC1_O4_STRING; + case 0x44115406: + return PT1000_SuS3_DEC1_O5_STRING; + case 0x44115407: + return PT1000_PVHC_DEC1_O6_STRING; + case 0x44115500: + return SPI_Test_Gyro_STRING; + case 0x44125401: + return PT1000_CCSDS1_DEC2_STRING; + case 0x44125403: + return PT1000_MGT1_DEC2_STRING; + case 0x44125404: + return PT1000_SuS4_DEC2_STRING; + case 0x44125405: + return PT1000_SuS5_DEC2_STRING; + case 0x44125406: + return PT1000_SuS6_DEC2_STRING; + case 0x44125407: + return PT1000_PVCH_DEC2_STRING; + case 0x44130301: + return PT1000_Iridium_DEC3_STRING; + case 0x44130302: + return PT1000_CCSDS2_DEC3_STRING; + case 0x44130305: + return PT1000_SuS7_DEC3_STRING; + case 0x44130306: + return PT1000_SuS8_DEC3_STRING; + case 0x44130307: + return PT1000_PVCH_DEC3_STRING; + case 0x44130308: + return GYRO2_STRING; + case 0x44145401: + return PT1000_PLOC_DEC4_STRING; + case 0x44145404: + return PT1000_SuS9_DEC4_STRING; + case 0x44145405: + return PT1000_SuS10_DEC4_STRING; + case 0x44145406: + return PT1000_PVHC_DEC4_STRING; + case 0x44145407: + return SuS_ADC_DEC4_STRING; + case 0x44202000: + return GPS1_HANDLER_STRING; + case 0x49001F00: + return DUMMY_GPS_COM_IF_STRING; + case 0x49005200: + return RS232_DEVICE_COM_IF_STRING; + case 0x49005300: + return I2C_DEVICE_COM_IF_STRING; + case 0x49005400: + return GPIO_DEVICE_COM_IF_STRING; + case 0x49005410: + return SPI_POLLING_TASK_STRING; + case 0x49005600: + return SPI_DEVICE_COM_IF_STRING; + case 0x4900AFFE: + return DUMMY_ECHO_COM_IF_STRING; + case 0x4D0073AD: + return SD_CARD_HANDLER_STRING; + case 0x50000100: + return CCSDS_PACKET_DISTRIBUTOR_STRING; + case 0x50000200: + return PUS_PACKET_DISTRIBUTOR_STRING; + case 0x50000300: + return UDP_TMTC_BRIDGE_STRING; + case 0x50000400: + return EMAC_POLLING_TASK_STRING; + case 0x50000500: + return SERIAL_TMTC_BRIDGE_STRING; + case 0x50000550: + return SERIAL_RING_BUFFER_STRING; + case 0x50000600: + return SERIAL_POLLING_TASK_STRING; + case 0x51000100: + return PUS_SERVICE_1_STRING; + case 0x51000200: + return PUS_SERVICE_2_STRING; + case 0x51000300: + return PUS_SERVICE_3_STRING; + case 0x51000310: + return PUS_SERVICE_3_PSB_STRING; + case 0x51000400: + return PUS_SERVICE_5_STRING; + case 0x51000500: + return PUS_SERVICE_6_STRING; + case 0x51000800: + return PUS_SERVICE_8_STRING; + case 0x51000900: + return PUS_SERVICE_9_STRING; + case 0x51001700: + return PUS_SERVICE_17_STRING; + case 0x51002000: + return PUS_SERVICE_20_STRING; + case 0x51002300: + return PUS_SERVICE_23_STRING; + case 0x51020000: + return PUS_SERVICE_200_STRING; + case 0x51020100: + return PUS_SERVICE_201_STRING; + case 0x52000001: + return PUS_TIME_STRING; + case 0x52000002: + return PUS_FUNNEL_STRING; + case 0x53000000: + return PUS_SERVICE_1_STRING; + case 0x53000003: + return FREERTOS_TASK_MONITOR_STRING; + case 0x53010000: + return HEALTH_TABLE_STRING; + case 0x53010100: + return MODE_STORE_STRING; + case 0x53030000: + return EVENT_MANAGER_STRING; + case 0x53040000: + return INTERNAL_ERROR_REPORTER_STRING; + case 0x534f0100: + return TC_STORE_STRING; + case 0x534f0200: + return TM_STORE_STRING; + case 0x534f0300: + return IPC_STORE_STRING; + case 0x66666666: + return AT91_SPI_TEST_TASK_STRING; + case 0x77777777: + return STM32_TEST_TASK_STRING; + case 0x87654321: + return AT91_UART0_TEST_TASK_STRING; + case 0x99000001: + return TC_INJECTOR_STRING; + case 0xFFFFFFFF: + return NO_OBJECT_STRING; + default: + return "UNKNOWN_OBJECT"; + } + return 0; +} diff --git a/defaultcfg/config/objects/translateObjects.h b/defaultcfg/config/objects/translateObjects.h new file mode 100644 index 00000000..5b656940 --- /dev/null +++ b/defaultcfg/config/objects/translateObjects.h @@ -0,0 +1,9 @@ +#ifndef CONFIG_OBJECTS_TRANSLATEOBJECTS_H_ +#define CONFIG_OBJECTS_TRANSLATEOBJECTS_H_ + +#include + +const char* translateObject(object_id_t object); + + +#endif /* CONFIG_OBJECTS_TRANSLATEOBJECTS_H_ */ diff --git a/defaultcfg/config/pollingsequence/PollingSequenceFactory.cpp b/defaultcfg/config/pollingsequence/PollingSequenceFactory.cpp new file mode 100644 index 00000000..f836a746 --- /dev/null +++ b/defaultcfg/config/pollingsequence/PollingSequenceFactory.cpp @@ -0,0 +1,23 @@ +#include "PollingSequenceFactory.h" + +#include +#include +#include + +ReturnValue_t pst::pollingSequenceInitDefault( + FixedTimeslotTaskIF *thisSequence) { + /* Length of a communication cycle */ + uint32_t length = thisSequence->getPeriodMs(); + + /* Add polling sequence table here */ + + if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_OK; + } + else { + sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } +} + diff --git a/defaultcfg/config/pollingsequence/PollingSequenceFactory.h b/defaultcfg/config/pollingsequence/PollingSequenceFactory.h new file mode 100644 index 00000000..c5d41b7d --- /dev/null +++ b/defaultcfg/config/pollingsequence/PollingSequenceFactory.h @@ -0,0 +1,32 @@ +#ifndef POLLINGSEQUENCEFACTORY_H_ +#define POLLINGSEQUENCEFACTORY_H_ + +#include + +class FixedTimeslotTaskIF; + +/** + * All device handlers are scheduled by adding them into Polling Sequence Tables (PST) + * to satisfy stricter timing requirements of device communication, + * A device handler has four different communication steps: + * 1. DeviceHandlerIF::SEND_WRITE -> Send write via interface + * 2. DeviceHandlerIF::GET_WRITE -> Get confirmation for write + * 3. DeviceHandlerIF::SEND_READ -> Send read request + * 4. DeviceHandlerIF::GET_READ -> Read from interface + * The PST specifies precisely when the respective ComIF functions are called + * during the communication cycle time. + * The task is created using the FixedTimeslotTaskIF, + * which utilises the underlying Operating System Abstraction Layer (OSAL) + * + * @param thisSequence FixedTimeslotTaskIF * object is passed inside the Factory class when creating the PST + * @return + */ +namespace pst { + +/* Default PST */ +ReturnValue_t pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence); + + +} + +#endif /* POLLINGSEQUENCEINIT_H_ */ diff --git a/defaultcfg/config/returnvalues/classIds.h b/defaultcfg/config/returnvalues/classIds.h new file mode 100644 index 00000000..606cc60b --- /dev/null +++ b/defaultcfg/config/returnvalues/classIds.h @@ -0,0 +1,16 @@ +#ifndef CONFIG_RETURNVALUES_CLASSIDS_H_ +#define CONFIG_RETURNVALUES_CLASSIDS_H_ + +#include + +/** + * @brief CLASS_ID defintions which are required for custom returnvalues. + */ +namespace CLASS_ID { +enum { + MISSION_CLASS_ID_START = FW_CLASS_ID_COUNT, +}; +} + + +#endif /* CONFIG_RETURNVALUES_CLASSIDS_H_ */ diff --git a/defaultcfg/config/tmtc/apid.h b/defaultcfg/config/tmtc/apid.h new file mode 100644 index 00000000..c0231bca --- /dev/null +++ b/defaultcfg/config/tmtc/apid.h @@ -0,0 +1,18 @@ +#ifndef CONFIG_TMTC_APID_H_ +#define CONFIG_TMTC_APID_H_ + +#include + +/** + * Application Process Definition: entity, uniquely identified by an + * application process ID (APID), capable of generating telemetry source + * packets and receiving telecommand packets. + * + * Chose APID(s) for mission and define it here. + */ +namespace apid { + static const uint16_t DEFAULT_APID = 0x00; +} + + +#endif /* CONFIG_TMTC_APID_H_ */ diff --git a/defaultcfg/config/tmtc/pusIds.h b/defaultcfg/config/tmtc/pusIds.h new file mode 100644 index 00000000..cc0db9f0 --- /dev/null +++ b/defaultcfg/config/tmtc/pusIds.h @@ -0,0 +1,23 @@ +#ifndef CONFIG_TMTC_PUSIDS_HPP_ +#define CONFIG_TMTC_PUSIDS_HPP_ + +namespace pus { +enum Ids: uint8_t { + PUS_SERVICE_1 = 1, + PUS_SERVICE_2 = 2, + PUS_SERVICE_3 = 3, + PUS_SERVICE_5 = 5, + PUS_SERVICE_6 = 6, + PUS_SERVICE_8 = 8, + PUS_SERVICE_9 = 9, + PUS_SERVICE_11 = 11, + PUS_SERVICE_17 = 17, + PUS_SERVICE_19 = 19, + PUS_SERVICE_20 = 20, + PUS_SERVICE_23 = 23, + PUS_SERVICE_200 = 200, + PUS_SERVICE_201 = 201, +}; +}; + +#endif /* CONFIG_TMTC_PUSIDS_HPP_ */ diff --git a/defaultcfg/config/version.h b/defaultcfg/config/version.h new file mode 100644 index 00000000..3c60317c --- /dev/null +++ b/defaultcfg/config/version.h @@ -0,0 +1,9 @@ +#ifndef CONFIG_VERSION_H_ +#define CONFIG_VERSION_H_ + +/* OBSW versioning can be specified in this file */ + +#define OBSW_VERSION 0 +#define OBSW_SUBVERSION 0 + +#endif /* CONFIG_VERSION_H_ */ diff --git a/defaultcfg/version.h b/defaultcfg/version.h new file mode 100644 index 00000000..b3ef8318 --- /dev/null +++ b/defaultcfg/version.h @@ -0,0 +1,11 @@ +#ifndef FSFW_DEFAULTCFG_VERSION_H_ +#define FSFW_DEFAULTCFG_VERSION_H_ + +static const char* FSFW_VERSION_NAME = "fsfw"; + +#define FSFW_VERSION 0 +#define FSFW_SUBVERSION 0 + + + +#endif /* FSFW_DEFAULTCFG_VERSION_H_ */ From 247c9f29479289b29475799fb4b74c07d553fb41 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 20 Oct 2020 17:39:11 +0200 Subject: [PATCH 05/26] added readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..fc86fca7 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +Flight Software Framework (FSFW) +====== + +I want to be written! From 1940a2acf02f9f36872163fff3d08bccfb132858 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 20 Oct 2020 17:44:27 +0200 Subject: [PATCH 06/26] some fixes --- defaultcfg/config/objects/systemObjectList.h | 130 +-------- .../config/objects/translateObjects.cpp | 271 ------------------ defaultcfg/config/objects/translateObjects.h | 9 - 3 files changed, 4 insertions(+), 406 deletions(-) delete mode 100644 defaultcfg/config/objects/translateObjects.cpp delete mode 100644 defaultcfg/config/objects/translateObjects.h diff --git a/defaultcfg/config/objects/systemObjectList.h b/defaultcfg/config/objects/systemObjectList.h index 2448efbd..f4292f6d 100644 --- a/defaultcfg/config/objects/systemObjectList.h +++ b/defaultcfg/config/objects/systemObjectList.h @@ -2,137 +2,15 @@ #define CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ #include +#include // The objects will be instantiated in the ID order namespace objects { enum sourceObjects: uint32_t { - /* First Byte 0x50-0x52 reserved for PUS Services **/ - CCSDS_PACKET_DISTRIBUTOR = 0x50000100, - PUS_PACKET_DISTRIBUTOR = 0x50000200, - /* UDP ID must come after CCSDS Distributor **/ - UDP_TMTC_BRIDGE = 0x50000300, - EMAC_POLLING_TASK = 0x50000400, - SERIAL_TMTC_BRIDGE = 0x50000500, - SERIAL_RING_BUFFER = 0x50000550, - SERIAL_POLLING_TASK = 0x50000600, - - PUS_SERVICE_6_MEM_MGMT = 0x51000500, - PUS_SERVICE_20_PARAM_MGMT = 0x51002000, - PUS_SERVICE_23_FILE_MGMT = 0x51002300, - PUS_SERVICE_201_HEALTH = 0x51020100, - - PUS_TIME = 0x52000001, - TM_FUNNEL = 0x52000002, - FREERTOS_TASK_MONITOR = 0x53000003, - - CORE_CONTROLLER = 0x40001000, - SYSTEM_STATE_TASK = 0x40001005, - THERMAL_CONTROLLER = 0x40002000, - RS485_CONTROLLER = 0x40005000, - - /* 0x44 ('D') for Device Handlers **/ - /* Second Byte: ComIF -> 0x00: UART,0x10 SPI,0x20: I2C,30: GPIO,40: PWM */ - /* Third Byte: Device ID */ - PCDU_HANDLER = 0x44003200, - GPS0_HANDLER = 0x44101F00, - GPS1_HANDLER = 0x44202000, - - DLR_PVCH = 0x44104000, - GYRO1 = 0x44105000, - DLR_IRAS = 0x44106000, - - /* fourth byte decoder output ID */ - - // Devices connected to decoder 1 - SPI_Test_PT1000 = 0x44115400, - SPI_Test_Gyro = 0x44115500, - PT1000_Syrlinks_DEC1_O1 = 0x44115401, - PT1000_Camera_DEC1_O2 = 0x44115402, - PT1000_SuS1_DEC1_O3 = 0x44115404, - PT1000_SuS2_DEC1_O4 = 0x44115405, - PT1000_SuS3_DEC1_O5 = 0x44115406, - PT1000_PVHC_DEC1_O6 = 0x44115407, - - // Devices connected to decoder 2 - PT1000_CCSDS1_DEC2 = 0x44125401, - PT1000_MGT1_DEC2 = 0x44125403, - PT1000_SuS4_DEC2 = 0x44125404, - PT1000_SuS5_DEC2 = 0x44125405, - PT1000_SuS6_DEC2 = 0x44125406, - PT1000_PVCH_DEC2 = 0x44125407, - SuS_ADC1_DEC2 = 0x44020108, - - // Devices connected to decoder 3 - PT1000_Iridium_DEC3 = 0x44130301, - PT1000_CCSDS2_DEC3 = 0x44130302, - PT1000_SuS7_DEC3 = 0x44130305, - PT1000_SuS8_DEC3 = 0x44130306, - PT1000_PVCH_DEC3 = 0x44130307, - GYRO2 = 0x44130308, - - // Devices connected to decoder 4 - PT1000_PLOC_DEC4 = 0x44145401, - PT1000_SuS9_DEC4 = 0x44145404, - PT1000_SuS10_DEC4 = 0x44145405, - PT1000_PVHC_DEC4 = 0x44145406, - SuS_ADC_DEC4 = 0x44145407, - - /* 0x49 ('I') for Communication Interfaces **/ - DUMMY_ECHO_COM_IF = 0x4900AFFE, - DUMMY_GPS_COM_IF = 0x49001F00, - RS232_DEVICE_COM_IF = 0x49005200, - I2C_DEVICE_COM_IF = 0x49005300, - GPIO_DEVICE_COM_IF = 0x49005400, - SPI_DEVICE_COM_IF = 0x49005600, - //SPI_POLLING_TASK = 0x49005410, - - /* 0x4d ('M') for Memory Handlers **/ - SD_CARD_HANDLER = 0x4D0073AD, - FRAM_HANDLER = 0x4D008000, - SOFTWARE_IMAGE_HANDLER = 0x4D009000, - - /* Board Specific */ - AT91_I2C_TEST_TASK = 0x12345678, - AT91_UART0_TEST_TASK = 0x87654321, - AT91_UART2_TEST_TASK = 0x000123336, - AT91_SPI_TEST_TASK = 0x66666666, - STM32_TEST_TASK = 0x77777777, - LED_TASK = 0x12345777, - - /* Test Task */ - ARDUINO_0 = 0x01010100, - ARDUINO_1 = 0x01010101, - ARDUINO_2 = 0x01010102, - ARDUINO_3 = 0x01010103, - ARDUINO_4 = 0x01010104, - TEST_TASK = 0x42694269, - DUMMY_HANDLER = 0x4400AFFE, - TC_INJECTOR = 0x99000001 + /* 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 }; } #endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ - - -/** - ▄ ▄ - ▌▒█ ▄▀▒▌ - ▌▒▒█ ▄▀▒▒▒▐ - ▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐ - ▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐ - ▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌ - ▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌ - ▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐ - ▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌ - ▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌ - ▌▒▀▐▄█▄█▌▄░▀▒▒░░░░░░░░░░▒▒▒▐ - ▐▒▒▐▀▐▀▒░▄▄▒▄▒▒▒▒▒▒░▒░▒░▒▒▒▒▌ - ▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▐ - ▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒░▒░▒░▒░▒▒▒▌ - ▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▄▒▒▐ - ▀▄▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▄▒▒▒▒▌ - ▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀ - ▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀ - ▒▒▒▒▒▒▒▒▒▒▀▀ -*/ - diff --git a/defaultcfg/config/objects/translateObjects.cpp b/defaultcfg/config/objects/translateObjects.cpp deleted file mode 100644 index 73cd02bf..00000000 --- a/defaultcfg/config/objects/translateObjects.cpp +++ /dev/null @@ -1,271 +0,0 @@ -/** - * @brief Auto-generated object translation file. Contains 86 translations. - * Generated on: 2020-08-25 00:57:14 - **/ -#include "translateObjects.h" - -const char *AT91_UART2_TEST_TASK_STRING = "AT91_UART2_TEST_TASK"; -const char *ARDUINO_0_STRING = "ARDUINO_0"; -const char *ARDUINO_1_STRING = "ARDUINO_1"; -const char *ARDUINO_2_STRING = "ARDUINO_2"; -const char *ARDUINO_3_STRING = "ARDUINO_3"; -const char *ARDUINO_4_STRING = "ARDUINO_4"; -const char *AT91_I2C_TEST_TASK_STRING = "AT91_I2C_TEST_TASK"; -const char *LED_TASK_STRING = "LED_TASK"; -const char *TEST_TASK_STRING = "TEST_TASK"; -const char *PCDU_HANDLER_STRING = "PCDU_HANDLER"; -const char *DUMMY_HANDLER_STRING = "DUMMY_HANDLER"; -const char *SuS_ADC1_DEC2_STRING = "SuS_ADC1_DEC2"; -const char *GPS0_HANDLER_STRING = "GPS0_HANDLER"; -const char *DLR_PVCH_STRING = "DLR_PVCH"; -const char *GYRO1_STRING = "GYRO1"; -const char *DLR_IRAS_STRING = "DLR_IRAS"; -const char *SPI_Test_PT1000_STRING = "SPI_Test_PT1000"; -const char *PT1000_Syrlinks_DEC1_O1_STRING = "PT1000_Syrlinks_DEC1_O1"; -const char *PT1000_Camera_DEC1_O2_STRING = "PT1000_Camera_DEC1_O2"; -const char *PT1000_SuS1_DEC1_O3_STRING = "PT1000_SuS1_DEC1_O3"; -const char *PT1000_SuS2_DEC1_O4_STRING = "PT1000_SuS2_DEC1_O4"; -const char *PT1000_SuS3_DEC1_O5_STRING = "PT1000_SuS3_DEC1_O5"; -const char *PT1000_PVHC_DEC1_O6_STRING = "PT1000_PVHC_DEC1_O6"; -const char *SPI_Test_Gyro_STRING = "SPI_Test_Gyro"; -const char *PT1000_CCSDS1_DEC2_STRING = "PT1000_CCSDS1_DEC2"; -const char *PT1000_MGT1_DEC2_STRING = "PT1000_MGT1_DEC2"; -const char *PT1000_SuS4_DEC2_STRING = "PT1000_SuS4_DEC2"; -const char *PT1000_SuS5_DEC2_STRING = "PT1000_SuS5_DEC2"; -const char *PT1000_SuS6_DEC2_STRING = "PT1000_SuS6_DEC2"; -const char *PT1000_PVCH_DEC2_STRING = "PT1000_PVCH_DEC2"; -const char *PT1000_Iridium_DEC3_STRING = "PT1000_Iridium_DEC3"; -const char *PT1000_CCSDS2_DEC3_STRING = "PT1000_CCSDS2_DEC3"; -const char *PT1000_SuS7_DEC3_STRING = "PT1000_SuS7_DEC3"; -const char *PT1000_SuS8_DEC3_STRING = "PT1000_SuS8_DEC3"; -const char *PT1000_PVCH_DEC3_STRING = "PT1000_PVCH_DEC3"; -const char *GYRO2_STRING = "GYRO2"; -const char *PT1000_PLOC_DEC4_STRING = "PT1000_PLOC_DEC4"; -const char *PT1000_SuS9_DEC4_STRING = "PT1000_SuS9_DEC4"; -const char *PT1000_SuS10_DEC4_STRING = "PT1000_SuS10_DEC4"; -const char *PT1000_PVHC_DEC4_STRING = "PT1000_PVHC_DEC4"; -const char *SuS_ADC_DEC4_STRING = "SuS_ADC_DEC4"; -const char *GPS1_HANDLER_STRING = "GPS1_HANDLER"; -const char *DUMMY_GPS_COM_IF_STRING = "DUMMY_GPS_COM_IF"; -const char *RS232_DEVICE_COM_IF_STRING = "RS232_DEVICE_COM_IF"; -const char *I2C_DEVICE_COM_IF_STRING = "I2C_DEVICE_COM_IF"; -const char *GPIO_DEVICE_COM_IF_STRING = "GPIO_DEVICE_COM_IF"; -const char *SPI_POLLING_TASK_STRING = "SPI_POLLING_TASK"; -const char *SPI_DEVICE_COM_IF_STRING = "SPI_DEVICE_COM_IF"; -const char *DUMMY_ECHO_COM_IF_STRING = "DUMMY_ECHO_COM_IF"; -const char *SD_CARD_HANDLER_STRING = "SD_CARD_HANDLER"; -const char *CCSDS_PACKET_DISTRIBUTOR_STRING = "CCSDS_PACKET_DISTRIBUTOR"; -const char *PUS_PACKET_DISTRIBUTOR_STRING = "PUS_PACKET_DISTRIBUTOR"; -const char *UDP_TMTC_BRIDGE_STRING = "UDP_TMTC_BRIDGE"; -const char *EMAC_POLLING_TASK_STRING = "EMAC_POLLING_TASK"; -const char *SERIAL_TMTC_BRIDGE_STRING = "SERIAL_TMTC_BRIDGE"; -const char *SERIAL_RING_BUFFER_STRING = "SERIAL_RING_BUFFER"; -const char *SERIAL_POLLING_TASK_STRING = "SERIAL_POLLING_TASK"; -const char *PUS_SERVICE_1_STRING = "PUS_SERVICE_1"; -const char *PUS_SERVICE_2_STRING = "PUS_SERVICE_2"; -const char *PUS_SERVICE_3_STRING = "PUS_SERVICE_3"; -const char *PUS_SERVICE_3_PSB_STRING = "PUS_SERVICE_3_PSB"; -const char *PUS_SERVICE_5_STRING = "PUS_SERVICE_5"; -const char *PUS_SERVICE_6_STRING = "PUS_SERVICE_6"; -const char *PUS_SERVICE_8_STRING = "PUS_SERVICE_8"; -const char *PUS_SERVICE_9_STRING = "PUS_SERVICE_9"; -const char *PUS_SERVICE_17_STRING = "PUS_SERVICE_17"; -const char *PUS_SERVICE_20_STRING = "PUS_SERVICE_20"; -const char *PUS_SERVICE_23_STRING = "PUS_SERVICE_23"; -const char *PUS_SERVICE_200_STRING = "PUS_SERVICE_200"; -const char *PUS_SERVICE_201_STRING = "PUS_SERVICE_201"; -const char *PUS_TIME_STRING = "PUS_TIME"; -const char *PUS_FUNNEL_STRING = "PUS_FUNNEL"; -const char *FREERTOS_TASK_MONITOR_STRING = "FREERTOS_TASK_MONITOR"; -const char *HEALTH_TABLE_STRING = "HEALTH_TABLE"; -const char *MODE_STORE_STRING = "MODE_STORE"; -const char *EVENT_MANAGER_STRING = "EVENT_MANAGER"; -const char *INTERNAL_ERROR_REPORTER_STRING = "INTERNAL_ERROR_REPORTER"; -const char *TC_STORE_STRING = "TC_STORE"; -const char *TM_STORE_STRING = "TM_STORE"; -const char *IPC_STORE_STRING = "IPC_STORE"; -const char *AT91_SPI_TEST_TASK_STRING = "AT91_SPI_TEST_TASK"; -const char *STM32_TEST_TASK_STRING = "STM32_TEST_TASK"; -const char *AT91_UART0_TEST_TASK_STRING = "AT91_UART0_TEST_TASK"; -const char *TC_INJECTOR_STRING = "TC_INJECTOR"; -const char *NO_OBJECT_STRING = "NO_OBJECT"; - -const char* translateObject(object_id_t object){ - switch((object&0xFFFFFFFF)){ - case 0x000123336: - return AT91_UART2_TEST_TASK_STRING; - case 0x01010100: - return ARDUINO_0_STRING; - case 0x01010101: - return ARDUINO_1_STRING; - case 0x01010102: - return ARDUINO_2_STRING; - case 0x01010103: - return ARDUINO_3_STRING; - case 0x01010104: - return ARDUINO_4_STRING; - case 0x12345678: - return AT91_I2C_TEST_TASK_STRING; - case 0x12345777: - return LED_TASK_STRING; - case 0x42694269: - return TEST_TASK_STRING; - case 0x44003200: - return PCDU_HANDLER_STRING; - case 0x4400AFFE: - return DUMMY_HANDLER_STRING; - case 0x44020108: - return SuS_ADC1_DEC2_STRING; - case 0x44101F00: - return GPS0_HANDLER_STRING; - case 0x44104000: - return DLR_PVCH_STRING; - case 0x44105000: - return GYRO1_STRING; - case 0x44106000: - return DLR_IRAS_STRING; - case 0x44115400: - return SPI_Test_PT1000_STRING; - case 0x44115401: - return PT1000_Syrlinks_DEC1_O1_STRING; - case 0x44115402: - return PT1000_Camera_DEC1_O2_STRING; - case 0x44115404: - return PT1000_SuS1_DEC1_O3_STRING; - case 0x44115405: - return PT1000_SuS2_DEC1_O4_STRING; - case 0x44115406: - return PT1000_SuS3_DEC1_O5_STRING; - case 0x44115407: - return PT1000_PVHC_DEC1_O6_STRING; - case 0x44115500: - return SPI_Test_Gyro_STRING; - case 0x44125401: - return PT1000_CCSDS1_DEC2_STRING; - case 0x44125403: - return PT1000_MGT1_DEC2_STRING; - case 0x44125404: - return PT1000_SuS4_DEC2_STRING; - case 0x44125405: - return PT1000_SuS5_DEC2_STRING; - case 0x44125406: - return PT1000_SuS6_DEC2_STRING; - case 0x44125407: - return PT1000_PVCH_DEC2_STRING; - case 0x44130301: - return PT1000_Iridium_DEC3_STRING; - case 0x44130302: - return PT1000_CCSDS2_DEC3_STRING; - case 0x44130305: - return PT1000_SuS7_DEC3_STRING; - case 0x44130306: - return PT1000_SuS8_DEC3_STRING; - case 0x44130307: - return PT1000_PVCH_DEC3_STRING; - case 0x44130308: - return GYRO2_STRING; - case 0x44145401: - return PT1000_PLOC_DEC4_STRING; - case 0x44145404: - return PT1000_SuS9_DEC4_STRING; - case 0x44145405: - return PT1000_SuS10_DEC4_STRING; - case 0x44145406: - return PT1000_PVHC_DEC4_STRING; - case 0x44145407: - return SuS_ADC_DEC4_STRING; - case 0x44202000: - return GPS1_HANDLER_STRING; - case 0x49001F00: - return DUMMY_GPS_COM_IF_STRING; - case 0x49005200: - return RS232_DEVICE_COM_IF_STRING; - case 0x49005300: - return I2C_DEVICE_COM_IF_STRING; - case 0x49005400: - return GPIO_DEVICE_COM_IF_STRING; - case 0x49005410: - return SPI_POLLING_TASK_STRING; - case 0x49005600: - return SPI_DEVICE_COM_IF_STRING; - case 0x4900AFFE: - return DUMMY_ECHO_COM_IF_STRING; - case 0x4D0073AD: - return SD_CARD_HANDLER_STRING; - case 0x50000100: - return CCSDS_PACKET_DISTRIBUTOR_STRING; - case 0x50000200: - return PUS_PACKET_DISTRIBUTOR_STRING; - case 0x50000300: - return UDP_TMTC_BRIDGE_STRING; - case 0x50000400: - return EMAC_POLLING_TASK_STRING; - case 0x50000500: - return SERIAL_TMTC_BRIDGE_STRING; - case 0x50000550: - return SERIAL_RING_BUFFER_STRING; - case 0x50000600: - return SERIAL_POLLING_TASK_STRING; - case 0x51000100: - return PUS_SERVICE_1_STRING; - case 0x51000200: - return PUS_SERVICE_2_STRING; - case 0x51000300: - return PUS_SERVICE_3_STRING; - case 0x51000310: - return PUS_SERVICE_3_PSB_STRING; - case 0x51000400: - return PUS_SERVICE_5_STRING; - case 0x51000500: - return PUS_SERVICE_6_STRING; - case 0x51000800: - return PUS_SERVICE_8_STRING; - case 0x51000900: - return PUS_SERVICE_9_STRING; - case 0x51001700: - return PUS_SERVICE_17_STRING; - case 0x51002000: - return PUS_SERVICE_20_STRING; - case 0x51002300: - return PUS_SERVICE_23_STRING; - case 0x51020000: - return PUS_SERVICE_200_STRING; - case 0x51020100: - return PUS_SERVICE_201_STRING; - case 0x52000001: - return PUS_TIME_STRING; - case 0x52000002: - return PUS_FUNNEL_STRING; - case 0x53000000: - return PUS_SERVICE_1_STRING; - case 0x53000003: - return FREERTOS_TASK_MONITOR_STRING; - case 0x53010000: - return HEALTH_TABLE_STRING; - case 0x53010100: - return MODE_STORE_STRING; - case 0x53030000: - return EVENT_MANAGER_STRING; - case 0x53040000: - return INTERNAL_ERROR_REPORTER_STRING; - case 0x534f0100: - return TC_STORE_STRING; - case 0x534f0200: - return TM_STORE_STRING; - case 0x534f0300: - return IPC_STORE_STRING; - case 0x66666666: - return AT91_SPI_TEST_TASK_STRING; - case 0x77777777: - return STM32_TEST_TASK_STRING; - case 0x87654321: - return AT91_UART0_TEST_TASK_STRING; - case 0x99000001: - return TC_INJECTOR_STRING; - case 0xFFFFFFFF: - return NO_OBJECT_STRING; - default: - return "UNKNOWN_OBJECT"; - } - return 0; -} diff --git a/defaultcfg/config/objects/translateObjects.h b/defaultcfg/config/objects/translateObjects.h deleted file mode 100644 index 5b656940..00000000 --- a/defaultcfg/config/objects/translateObjects.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef CONFIG_OBJECTS_TRANSLATEOBJECTS_H_ -#define CONFIG_OBJECTS_TRANSLATEOBJECTS_H_ - -#include - -const char* translateObject(object_id_t object); - - -#endif /* CONFIG_OBJECTS_TRANSLATEOBJECTS_H_ */ From e4d323683d478118ea4f59d1ace3f684fa37793d Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 20 Oct 2020 17:47:52 +0200 Subject: [PATCH 07/26] readme fix --- defaultcfg/config/objects/Factory.cpp | 31 ++++++++++++--------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/defaultcfg/config/objects/Factory.cpp b/defaultcfg/config/objects/Factory.cpp index ea187a5e..51dd6130 100644 --- a/defaultcfg/config/objects/Factory.cpp +++ b/defaultcfg/config/objects/Factory.cpp @@ -1,11 +1,9 @@ #include "Factory.h" - -/* Config */ -#include -#include -#include -#include -#include +#include "../tmtc/apid.h" +#include "../tmtc/pusIds.h" +#include "../objects/systemObjectList.h" +#include "../devices/logicalAddresses.h" +#include "../devices/powerSwitcherList.h" #include #include @@ -13,21 +11,20 @@ #include #include #include -#include - #include - /** - * 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 nterface validity is checked or retrieved later by using the - * get(object_id) function from the ObjectManagerIF. + * This class should be used to create all system objects required for + * the on-board software, using the object ID list from the configuration + * folder. + * + * The objects are registered in the internal object manager automatically. + * This is used later to add objects to tasks. + * + * This file also sets static framework IDs. * * Framework objects are created first. - * * @ingroup init */ void Factory::produce(void) { @@ -52,6 +49,6 @@ void Factory::setStaticFrameworkObjectIds() { DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT; TmPacketStored::timeStamperId = objects::PUS_TIME; - TmFunnel::downlinkDestination = objects::NO_OBJECT; + //TmFunnel::downlinkDestination = objects::NO_OBJECT; } From ede00dfdcc5f4bb5b90093b473b84013b6cc1d83 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 20 Oct 2020 17:50:10 +0200 Subject: [PATCH 08/26] double files removed, versioning files renamed --- defaultcfg/version.h => FSFWVersion.h | 0 defaultcfg/FSFWConfig.h | 41 ------------------- .../config/{version.h => OBSWVersion.h} | 0 3 files changed, 41 deletions(-) rename defaultcfg/version.h => FSFWVersion.h (100%) delete mode 100644 defaultcfg/FSFWConfig.h rename defaultcfg/config/{version.h => OBSWVersion.h} (100%) diff --git a/defaultcfg/version.h b/FSFWVersion.h similarity index 100% rename from defaultcfg/version.h rename to FSFWVersion.h diff --git a/defaultcfg/FSFWConfig.h b/defaultcfg/FSFWConfig.h deleted file mode 100644 index 2001f306..00000000 --- a/defaultcfg/FSFWConfig.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef CONFIG_FSFWCONFIG_H_ -#define CONFIG_FSFWCONFIG_H_ - -#include "version.h" - -//! Used to determine whether C++ ostreams are used -//! Those can lead to code bloat. -#define FSFW_CPP_OSTREAM_ENABLED 1 - -//! Reduced printout to further decrese code size -//! Be careful, this also turns off most diagnostic prinouts! -#define FSFW_REDUCED_PRINTOUT 0 - -//! Can be used to enable debugging printouts for developing the FSFW -#define FSFW_DEBUGGING 0 - -//! Defines the FIFO depth of each commanding service base which -//! also determines how many commands a CSB service can handle in one cycle -//! simulataneously. This will increase the required RAM for -//! each CSB service ! -#define FSFW_CSB_FIFO_DEPTH 6 - -//! If -DDEBUG is supplied in the build defines, there will be -//! additional output which requires the translation files translateObjects -//! and translateEvents (and their compiles source files) -#ifdef DEBUG -#define FSFW_DEBUG_OUTPUT 1 -//! Specify whether info events are printed too. -#define FSFW_DEBUG_INFO 1 -#include -#include -#else -#define FSFW_DEBUG_OUTPUT 0 -#endif - -//! When using the newlib nano library, C99 support for stdio facilities -//! will not be provided. This define should be set to 1 if this is the case. -#define FSFW_NO_C99_IO 1 - - -#endif /* CONFIG_FSFWCONFIG_H_ */ diff --git a/defaultcfg/config/version.h b/defaultcfg/config/OBSWVersion.h similarity index 100% rename from defaultcfg/config/version.h rename to defaultcfg/config/OBSWVersion.h From 29a796ebdb85ca62ab6d90ec5519d561a51de40a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 20 Oct 2020 17:51:13 +0200 Subject: [PATCH 09/26] include names fixed --- defaultcfg/config/FSFWConfig.h | 2 +- defaultcfg/config/OBSWConfig.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/defaultcfg/config/FSFWConfig.h b/defaultcfg/config/FSFWConfig.h index 2001f306..cfe89864 100644 --- a/defaultcfg/config/FSFWConfig.h +++ b/defaultcfg/config/FSFWConfig.h @@ -1,7 +1,7 @@ #ifndef CONFIG_FSFWCONFIG_H_ #define CONFIG_FSFWCONFIG_H_ -#include "version.h" +#include //! Used to determine whether C++ ostreams are used //! Those can lead to code bloat. diff --git a/defaultcfg/config/OBSWConfig.h b/defaultcfg/config/OBSWConfig.h index d186da7d..a9f57638 100644 --- a/defaultcfg/config/OBSWConfig.h +++ b/defaultcfg/config/OBSWConfig.h @@ -1,6 +1,8 @@ #ifndef CONFIG_OBSWCONFIG_H_ #define CONFIG_OBSWCONFIG_H_ +#include "OBSWVersion.h" + #ifdef __cplusplus namespace config { #endif From 6cce062d622a126a7eca831b3f3070bfdc6c6f21 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 20 Oct 2020 17:52:43 +0200 Subject: [PATCH 10/26] some more fixes --- defaultcfg/config/objects/Factory.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/defaultcfg/config/objects/Factory.h b/defaultcfg/config/objects/Factory.h index 8b99ae99..fe55deff 100644 --- a/defaultcfg/config/objects/Factory.h +++ b/defaultcfg/config/objects/Factory.h @@ -5,15 +5,12 @@ #include namespace Factory { - size_t calculateStorage(uint8_t numberOfPools, uint16_t* numberOfElements, - uint16_t* sizeOfElements); /** * @brief Creates all SystemObject elements which are persistent * during execution. */ void produce(); void setStaticFrameworkObjectIds(); - } From 4dd79b349515ca0606d2fa7d5c29089c3b56da5c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 29 Oct 2020 15:16:16 +0100 Subject: [PATCH 11/26] not static anymore --- FSFWVersion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FSFWVersion.h b/FSFWVersion.h index b3ef8318..dcb592dc 100644 --- a/FSFWVersion.h +++ b/FSFWVersion.h @@ -1,7 +1,7 @@ #ifndef FSFW_DEFAULTCFG_VERSION_H_ #define FSFW_DEFAULTCFG_VERSION_H_ -static const char* FSFW_VERSION_NAME = "fsfw"; +const char* const FSFW_VERSION_NAME = "fsfw"; #define FSFW_VERSION 0 #define FSFW_SUBVERSION 0 From 27e0b9cf380a778e425c08e3c9c77ec7cc521a08 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 29 Oct 2020 15:17:13 +0100 Subject: [PATCH 12/26] default FIFO depth is 5 now --- defaultcfg/config/FSFWConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaultcfg/config/FSFWConfig.h b/defaultcfg/config/FSFWConfig.h index cfe89864..a5aaa125 100644 --- a/defaultcfg/config/FSFWConfig.h +++ b/defaultcfg/config/FSFWConfig.h @@ -18,7 +18,7 @@ //! also determines how many commands a CSB service can handle in one cycle //! simulataneously. This will increase the required RAM for //! each CSB service ! -#define FSFW_CSB_FIFO_DEPTH 6 +#define FSFW_CSB_FIFO_DEPTH 4 //! If -DDEBUG is supplied in the build defines, there will be //! additional output which requires the translation files translateObjects From 64c341b5f686cbd7921b75e879017c93b94dcf6e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 29 Oct 2020 15:17:33 +0100 Subject: [PATCH 13/26] now really five --- defaultcfg/config/FSFWConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaultcfg/config/FSFWConfig.h b/defaultcfg/config/FSFWConfig.h index a5aaa125..945992df 100644 --- a/defaultcfg/config/FSFWConfig.h +++ b/defaultcfg/config/FSFWConfig.h @@ -18,7 +18,7 @@ //! also determines how many commands a CSB service can handle in one cycle //! simulataneously. This will increase the required RAM for //! each CSB service ! -#define FSFW_CSB_FIFO_DEPTH 4 +#define FSFW_CSB_FIFO_DEPTH 5 //! If -DDEBUG is supplied in the build defines, there will be //! additional output which requires the translation files translateObjects From 9af5855ece0310e53c33a81ba2409b909ebbee98 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 29 Oct 2020 15:23:14 +0100 Subject: [PATCH 14/26] event stuff added --- defaultcfg/config/FSFWConfig.h | 8 ++++++++ events/EventManager.cpp | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/defaultcfg/config/FSFWConfig.h b/defaultcfg/config/FSFWConfig.h index 945992df..67c04225 100644 --- a/defaultcfg/config/FSFWConfig.h +++ b/defaultcfg/config/FSFWConfig.h @@ -2,6 +2,7 @@ #define CONFIG_FSFWCONFIG_H_ #include +#include //! Used to determine whether C++ ostreams are used //! Those can lead to code bloat. @@ -37,5 +38,12 @@ //! will not be provided. This define should be set to 1 if this is the case. #define FSFW_NO_C99_IO 1 +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; +} + #endif /* CONFIG_FSFWCONFIG_H_ */ diff --git a/events/EventManager.cpp b/events/EventManager.cpp index e71951e3..3bce53eb 100644 --- a/events/EventManager.cpp +++ b/events/EventManager.cpp @@ -12,7 +12,6 @@ const uint16_t EventManager::POOL_SIZES[N_POOLS] = { // objects registering for certain events. // Each listener requires 1 or 2 EventIdMatcher and 1 or 2 ReportRangeMatcher. // So a good guess is 75 to a max of 100 pools required for each, which fits well. -// SHOULDDO: Shouldn't this be in the config folder and passed via ctor? const uint16_t EventManager::N_ELEMENTS[N_POOLS] = { 240, 120, 120 }; EventManager::EventManager(object_id_t setObjectId) : From 78896323b6a67e995508592c0a313917a2e72e7a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 29 Oct 2020 17:09:43 +0100 Subject: [PATCH 15/26] fsfw config update --- defaultcfg/config/FSFWConfig.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/defaultcfg/config/FSFWConfig.h b/defaultcfg/config/FSFWConfig.h index 67c04225..ea724a64 100644 --- a/defaultcfg/config/FSFWConfig.h +++ b/defaultcfg/config/FSFWConfig.h @@ -12,6 +12,10 @@ //! Be careful, this also turns off most diagnostic prinouts! #define FSFW_REDUCED_PRINTOUT 0 +//! Default timestamp size. The default timestamp will be an eight byte CDC +//! short timestamp. +#define FSFW_MISSION_TIMESTAMP_SIZE 8 + //! Can be used to enable debugging printouts for developing the FSFW #define FSFW_DEBUGGING 0 @@ -19,12 +23,14 @@ //! also determines how many commands a CSB service can handle in one cycle //! simulataneously. This will increase the required RAM for //! each CSB service ! -#define FSFW_CSB_FIFO_DEPTH 5 +#define FSFW_CSB_FIFO_DEPTH 6 -//! If -DDEBUG is supplied in the build defines, there will be +//! If FSFW_OBJ_EVENT_TRANSLATION is set to one, //! additional output which requires the translation files translateObjects -//! and translateEvents (and their compiles source files) -#ifdef DEBUG +//! and translateEvents (and their compiled source files) +#define FSFW_OBJ_EVENT_TRANSLATION 0 + +#if FSFW_OBJ_EVENT_TRANSLATION == 1 #define FSFW_DEBUG_OUTPUT 1 //! Specify whether info events are printed too. #define FSFW_DEBUG_INFO 1 @@ -45,5 +51,4 @@ static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120; static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; } - #endif /* CONFIG_FSFWCONFIG_H_ */ From f5b0589f792408bbac2a16e1a0394d6997191abe Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 29 Oct 2020 17:28:33 +0100 Subject: [PATCH 16/26] event manager update --- events/EventManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/events/EventManager.cpp b/events/EventManager.cpp index 3bce53eb..f60a8a66 100644 --- a/events/EventManager.cpp +++ b/events/EventManager.cpp @@ -1,5 +1,7 @@ #include "EventManager.h" #include "EventMessage.h" +#include + #include "../serviceinterface/ServiceInterfaceStream.h" #include "../ipc/QueueFactory.h" #include "../ipc/MutexFactory.h" @@ -12,7 +14,10 @@ const uint16_t EventManager::POOL_SIZES[N_POOLS] = { // objects registering for certain events. // Each listener requires 1 or 2 EventIdMatcher and 1 or 2 ReportRangeMatcher. // So a good guess is 75 to a max of 100 pools required for each, which fits well. -const uint16_t EventManager::N_ELEMENTS[N_POOLS] = { 240, 120, 120 }; +const uint16_t EventManager::N_ELEMENTS[N_POOLS] = { + fsfwconfig::FSFW_EVENTMGMR_MATCHTREE_NODES , + fsfwconfig::FSFW_EVENTMGMT_EVENTIDMATCHERS, + fsfwconfig::FSFW_EVENTMGMR_RANGEMATCHERS }; EventManager::EventManager(object_id_t setObjectId) : SystemObject(setObjectId), From 9b5e9409656fcd7b5c32fdbdb73fe55de5804aaa Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 29 Oct 2020 17:32:07 +0100 Subject: [PATCH 17/26] config make fix --- defaultcfg/{ => config}/config.mk | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) rename defaultcfg/{ => config}/config.mk (50%) diff --git a/defaultcfg/config.mk b/defaultcfg/config/config.mk similarity index 50% rename from defaultcfg/config.mk rename to defaultcfg/config/config.mk index fcf3b799..c9584114 100644 --- a/defaultcfg/config.mk +++ b/defaultcfg/config/config.mk @@ -6,12 +6,10 @@ CXXSRC += $(wildcard $(CURRENTPATH)/config/tmtc/*.cpp) CXXSRC += $(wildcard $(CURRENTPATH)/config/devices/*.cpp) INCLUDES += $(CURRENTPATH) -INCLUDES += $(CURRENTPATH)/config/ -INCLUDES += $(CURRENTPATH)/config/objects -INCLUDES += $(CURRENTPATH)/config/returnvalues -INCLUDES += $(CURRENTPATH)/config/tmtc -INCLUDES += $(CURRENTPATH)/config/events -INCLUDES += $(CURRENTPATH)/config/devices -INCLUDES += $(CURRENTPATH)/config/pollingsequence -INCLUDES += $(CURRENTPATH)/config/ipc -INCLUDES += $(CURRENTPATH)/config/ +INCLUDES += $(CURRENTPATH)/objects +INCLUDES += $(CURRENTPATH)/returnvalues +INCLUDES += $(CURRENTPATH)/tmtc +INCLUDES += $(CURRENTPATH)/events +INCLUDES += $(CURRENTPATH)/devices +INCLUDES += $(CURRENTPATH)/pollingsequence +INCLUDES += $(CURRENTPATH)/ipc From af4c6f1d45fd9a42f5f0a189765671c6b89d9b21 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 29 Oct 2020 17:33:40 +0100 Subject: [PATCH 18/26] config mk update --- defaultcfg/config/config.mk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/defaultcfg/config/config.mk b/defaultcfg/config/config.mk index c9584114..51543eba 100644 --- a/defaultcfg/config/config.mk +++ b/defaultcfg/config/config.mk @@ -1,9 +1,9 @@ -CXXSRC += $(wildcard $(CURRENTPATH)/config/ipc/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/config/objects/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/config/pollingsequence/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/config/events/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/config/tmtc/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/config/devices/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/ipc/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/objects/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/pollingsequence/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/events/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/tmtc/*.cpp) +CXXSRC += $(wildcard $(CURRENTPATH)/devices/*.cpp) INCLUDES += $(CURRENTPATH) INCLUDES += $(CURRENTPATH)/objects From e35aebcd0af19c9f96fa6a173963737edd639fea Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 29 Oct 2020 17:45:06 +0100 Subject: [PATCH 19/26] HasREturnvalue update --- returnvalues/HasReturnvaluesIF.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/returnvalues/HasReturnvaluesIF.h b/returnvalues/HasReturnvaluesIF.h index 5fef91dd..a39ac742 100644 --- a/returnvalues/HasReturnvaluesIF.h +++ b/returnvalues/HasReturnvaluesIF.h @@ -1,8 +1,8 @@ -#ifndef FRAMEWORK_RETURNVALUES_HASRETURNVALUESIF_H_ -#define FRAMEWORK_RETURNVALUES_HASRETURNVALUESIF_H_ +#ifndef FSFW_RETURNVALUES_HASRETURNVALUESIF_H_ +#define FSFW_RETURNVALUES_HASRETURNVALUESIF_H_ #include "FwClassIds.h" -#include +#include #include #define MAKE_RETURN_CODE( number ) ((INTERFACE_ID << 8) + (number)) @@ -15,9 +15,17 @@ public: static const ReturnValue_t RETURN_FAILED = 1; virtual ~HasReturnvaluesIF() {} - static ReturnValue_t makeReturnCode(uint8_t interfaceId, uint8_t number) { + /** + * 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 interfaceId, + uint8_t number) { return (interfaceId << 8) + number; } }; -#endif /* FRAMEWORK_RETURNVALUES_HASRETURNVALUESIF_H_ */ +#endif /* FSFW_RETURNVALUES_HASRETURNVALUESIF_H_ */ From 3098f34eb0988a22f9642b60e4f61c3b65f67aed Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 29 Oct 2020 17:52:28 +0100 Subject: [PATCH 20/26] health update --- health/HasHealthIF.h | 25 +++++++++--------- health/HealthHelper.h | 45 ++++++++++++++++++------------- health/HealthMessage.cpp | 6 +++-- health/HealthMessage.h | 20 +++++++++----- health/HealthTable.cpp | 57 ++++++++++++++++------------------------ health/HealthTable.h | 33 ++++++++++++++--------- health/HealthTableIF.h | 18 ++++++------- health/ManagesHealthIF.h | 7 ++--- 8 files changed, 112 insertions(+), 99 deletions(-) diff --git a/health/HasHealthIF.h b/health/HasHealthIF.h index ac404300..86863ea8 100644 --- a/health/HasHealthIF.h +++ b/health/HasHealthIF.h @@ -1,5 +1,5 @@ -#ifndef HASHEALTHIF_H_ -#define HASHEALTHIF_H_ +#ifndef FSFW_HEALTH_HASHEALTHIF_H_ +#define FSFW_HEALTH_HASHEALTHIF_H_ #include "../events/Event.h" #include "../returnvalues/HasReturnvaluesIF.h" @@ -8,9 +8,13 @@ class HasHealthIF { public: - typedef enum { - HEALTHY = 1, FAULTY = 0, EXTERNAL_CONTROL = 2, NEEDS_RECOVERY = 3, PERMANENT_FAULTY = 4 - } HealthState; + enum HealthState: uint8_t { + HEALTHY = 1, + FAULTY = 0, + EXTERNAL_CONTROL = 2, + NEEDS_RECOVERY = 3, + PERMANENT_FAULTY = 4 + }; static const uint8_t INTERFACE_ID = CLASS_ID::HAS_HEALTH_IF; static const ReturnValue_t OBJECT_NOT_HEALTHY = MAKE_RETURN_CODE(1); @@ -31,20 +35,17 @@ public: virtual MessageQueueId_t getCommandQueue() const = 0; /** - * set the Health State - * + * @brief Set the Health State * The parent will be informed, if the Health changes - * * @param health */ virtual ReturnValue_t setHealth(HealthState health) = 0; /** - * get Health State - * - * @return Health State of the object + * @brief Get Health State + * @return Health State of the object */ virtual HasHealthIF::HealthState getHealth() = 0; }; -#endif /* HASHEALTHIF_H_ */ +#endif /* FSFW_HEALTH_HASHEALTHIF_H_ */ diff --git a/health/HealthHelper.h b/health/HealthHelper.h index d1f1945c..08889fba 100644 --- a/health/HealthHelper.h +++ b/health/HealthHelper.h @@ -12,13 +12,15 @@ #include "../returnvalues/HasReturnvaluesIF.h" /** - * Helper class for Objects that implement HasHealthIF + * @brief Helper class for Objects that implement HasHealthIF + * @details + * It takes care of registering with the Health Table as well as handling + * health commands (including replying to the sender) and updating + * the Health Table. * - * It takes care of registering with the Health Table as well as handling health commands - * (including replying to the sender) and updating the Health Table. - * - * If a parent is set in the ctor, the parent will be informed with a @c HEALTH_INFO message - * about changes in the health state. Note that a @c HEALTH_INFO is only generated if the Health + * If a parent is set in the ctor, the parent will be informed with a + * @c HEALTH_INFO message about changes in the health state. + * Note that a @c HEALTH_INFO is only generated if the Health * changes, not for all @c HEALTH_SET commands received. * * It does NOT handle @c HEALTH_INFO messages @@ -27,10 +29,9 @@ class HealthHelper { public: /** - * ctor - * * @param owner - * @param objectId the object Id to use when communication with the HealthTable + * @param objectId The object Id to use when communication with + * the HealthTable */ HealthHelper(HasHealthIF* owner, object_id_t objectId); @@ -56,8 +57,9 @@ public: * * @param message * @return - * -@c RETURN_OK if the message was handled - * -@c RETURN_FAILED if the message could not be handled (ie it was not a @c HEALTH_SET or @c HEALTH_READ message) + * -@c RETURN_OK if the message was handled + * -@c RETURN_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); @@ -78,16 +80,19 @@ public: HasHealthIF::HealthState getHealth(); /** - * @param parentQueue the Queue id of the parent object. Set to 0 if no parent present + * @param parentQueue The queue ID of the parent object. + * Set to 0 if no parent present */ void setParentQueue(MessageQueueId_t parentQueue); /** * - * @param parentQueue the Queue id of the parent object. Set to 0 if no parent present + * @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 could be registered - * -@c RETURN_FAILED else + * -@c RETURN_OK if the Health Table was found and the object + * could be registered + * -@c RETURN_FAILED else */ ReturnValue_t initialize(MessageQueueId_t parentQueue ); @@ -110,11 +115,15 @@ private: HasHealthIF* owner; /** - * if the #parentQueue is not NULL, a @c HEALTH_INFO message will be sent to this queue - * @param health the health is passed as parameter so that the number of calls to the health table can be minimized + * if the #parentQueue is not NULL, a @c HEALTH_INFO message + * will be sent to this queue + * @param health + * The health is passed as parameter so that the number of + * calls to the health table can be minimized * @param oldHealth information of the previous health state. */ - void informParent(HasHealthIF::HealthState health, HasHealthIF::HealthState oldHealth); + void informParent(HasHealthIF::HealthState health, + HasHealthIF::HealthState oldHealth); void handleSetHealthCommand(CommandMessage *message); }; diff --git a/health/HealthMessage.cpp b/health/HealthMessage.cpp index 1bb29526..52479c26 100644 --- a/health/HealthMessage.cpp +++ b/health/HealthMessage.cpp @@ -7,11 +7,13 @@ void HealthMessage::setHealthMessage(CommandMessage* message, Command_t command, message->setParameter2(oldHealth); } -void HealthMessage::setHealthMessage(CommandMessage* message, Command_t command) { +void HealthMessage::setHealthMessage(CommandMessage* message, + Command_t command) { message->setCommand(command); } -HasHealthIF::HealthState HealthMessage::getHealth(const CommandMessage* message) { +HasHealthIF::HealthState HealthMessage::getHealth( + const CommandMessage* message) { return (HasHealthIF::HealthState) message->getParameter(); } diff --git a/health/HealthMessage.h b/health/HealthMessage.h index db2a7719..fb979c66 100644 --- a/health/HealthMessage.h +++ b/health/HealthMessage.h @@ -1,5 +1,5 @@ -#ifndef HEALTHMESSAGE_H_ -#define HEALTHMESSAGE_H_ +#ifndef FSFW_HEALTH_HEALTHMESSAGE_H_ +#define FSFW_HEALTH_HEALTHMESSAGE_H_ #include "HasHealthIF.h" #include "../ipc/CommandMessage.h" @@ -7,14 +7,20 @@ class HealthMessage { public: static const uint8_t MESSAGE_ID = messagetypes::HEALTH_COMMAND; - static const Command_t HEALTH_SET = MAKE_COMMAND_ID(1);//REPLY_COMMAND_OK/REPLY_REJECTED - static const Command_t HEALTH_ANNOUNCE = MAKE_COMMAND_ID(3); //NO REPLY! + + static const Command_t HEALTH_SET = MAKE_COMMAND_ID(1); + // No reply expected, health will be announced as event! + static const Command_t HEALTH_ANNOUNCE = MAKE_COMMAND_ID(2); + // Same as before, but all objects in health table will + // announce their health as events. + static const Command_t HEALTH_ANNOUNCE_ALL = MAKE_COMMAND_ID(3); + static const Command_t HEALTH_INFO = MAKE_COMMAND_ID(5); static const Command_t REPLY_HEALTH_SET = MAKE_COMMAND_ID(6); static void setHealthMessage(CommandMessage *message, Command_t command, - HasHealthIF::HealthState health, HasHealthIF::HealthState oldHealth = HasHealthIF::FAULTY); - + HasHealthIF::HealthState health, + HasHealthIF::HealthState oldHealth = HasHealthIF::FAULTY); static void setHealthMessage(CommandMessage *message, Command_t command); static HasHealthIF::HealthState getHealth(const CommandMessage *message); @@ -27,4 +33,4 @@ private: HealthMessage(); }; -#endif /* HEALTHMESSAGE_H_ */ +#endif /* FSFW_HEALTH_HEALTHMESSAGE_H_ */ diff --git a/health/HealthTable.cpp b/health/HealthTable.cpp index 4d2564a3..6d6fe017 100644 --- a/health/HealthTable.cpp +++ b/health/HealthTable.cpp @@ -1,6 +1,7 @@ #include "HealthTable.h" -#include "../serialize/SerializeAdapter.h" +#include "../ipc/MutexHelper.h" #include "../ipc/MutexFactory.h" +#include "../serialize/SerializeAdapter.h" HealthTable::HealthTable(object_id_t objectid) : SystemObject(objectid) { @@ -18,74 +19,64 @@ ReturnValue_t HealthTable::registerObject(object_id_t object, if (healthMap.count(object) != 0) { return HasReturnvaluesIF::RETURN_FAILED; } - healthMap.insert( - std::pair(object, - initilialState)); + healthMap.emplace(object, initilialState); return HasReturnvaluesIF::RETURN_OK; } void HealthTable::setHealth(object_id_t object, HasHealthIF::HealthState newState) { - mutex->lockMutex(MutexIF::BLOCKING); + MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); HealthMap::iterator iter = healthMap.find(object); if (iter != healthMap.end()) { iter->second = newState; } - mutex->unlockMutex(); } HasHealthIF::HealthState HealthTable::getHealth(object_id_t object) { HasHealthIF::HealthState state = HasHealthIF::HEALTHY; - mutex->lockMutex(MutexIF::BLOCKING); + MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); HealthMap::iterator iter = healthMap.find(object); if (iter != healthMap.end()) { state = iter->second; } - mutex->unlockMutex(); return state; } -uint32_t HealthTable::getPrintSize() { - mutex->lockMutex(MutexIF::BLOCKING); - uint32_t size = healthMap.size() * 5 + 2; - mutex->unlockMutex(); - return size; -} bool HealthTable::hasHealth(object_id_t object) { - bool exits = false; - mutex->lockMutex(MutexIF::BLOCKING); + MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); HealthMap::iterator iter = healthMap.find(object); if (iter != healthMap.end()) { - exits = true; + return true; } - mutex->unlockMutex(); - return exits; + return false; +} + +size_t HealthTable::getPrintSize() { + MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); + uint32_t size = healthMap.size() * sizeof(object_id_t) + + sizeof(HasHealthIF::HealthState) + sizeof(uint16_t); + return size; } void HealthTable::printAll(uint8_t* pointer, size_t maxSize) { - mutex->lockMutex(MutexIF::BLOCKING); + MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); size_t size = 0; uint16_t count = healthMap.size(); - ReturnValue_t result = SerializeAdapter::serialize(&count, + SerializeAdapter::serialize(&count, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); - HealthMap::iterator iter; - for (iter = healthMap.begin(); - iter != healthMap.end() && result == HasReturnvaluesIF::RETURN_OK; - ++iter) { - result = SerializeAdapter::serialize(&iter->first, + for (const auto& health: healthMap) { + SerializeAdapter::serialize(&health.first, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); - uint8_t health = iter->second; - result = SerializeAdapter::serialize(&health, &pointer, &size, + uint8_t healthValue = health.second; + SerializeAdapter::serialize(&healthValue, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); } - mutex->unlockMutex(); } -ReturnValue_t HealthTable::iterate( - std::pair *value, bool reset) { +ReturnValue_t HealthTable::iterate(HealthEntry *value, bool reset) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - mutex->lockMutex(MutexIF::BLOCKING); + MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); if (reset) { mapIterator = healthMap.begin(); } @@ -94,7 +85,5 @@ ReturnValue_t HealthTable::iterate( } *value = *mapIterator; mapIterator++; - mutex->unlockMutex(); - return result; } diff --git a/health/HealthTable.h b/health/HealthTable.h index 6f5dd18d..945fb2e6 100644 --- a/health/HealthTable.h +++ b/health/HealthTable.h @@ -1,35 +1,42 @@ -#ifndef HEALTHTABLE_H_ -#define HEALTHTABLE_H_ +#ifndef FSFW_HEALTH_HEALTHTABLE_H_ +#define FSFW_HEALTH_HEALTHTABLE_H_ #include "HealthTableIF.h" #include "../objectmanager/SystemObject.h" #include "../ipc/MutexIF.h" #include -typedef std::map HealthMap; class HealthTable: public HealthTableIF, public SystemObject { public: HealthTable(object_id_t objectid); virtual ~HealthTable(); - virtual ReturnValue_t registerObject(object_id_t object, - HasHealthIF::HealthState initilialState = HasHealthIF::HEALTHY); + /** HealthTableIF overrides */ + virtual ReturnValue_t registerObject(object_id_t object, + HasHealthIF::HealthState initilialState = + HasHealthIF::HEALTHY) override; + virtual size_t getPrintSize() override; + virtual void printAll(uint8_t *pointer, size_t maxSize) override; - virtual bool hasHealth(object_id_t object); - virtual void setHealth(object_id_t object, HasHealthIF::HealthState newState); - virtual HasHealthIF::HealthState getHealth(object_id_t); - - virtual uint32_t getPrintSize(); - virtual void printAll(uint8_t *pointer, size_t maxSize); + /** ManagesHealthIF overrides */ + virtual bool hasHealth(object_id_t object) override; + virtual void setHealth(object_id_t object, + HasHealthIF::HealthState newState) override; + virtual HasHealthIF::HealthState getHealth(object_id_t) override; protected: + using HealthMap = std::map; + using HealthEntry = std::pair; + MutexIF* mutex; HealthMap healthMap; HealthMap::iterator mapIterator; - virtual ReturnValue_t iterate(std::pair *value, bool reset = false); + virtual ReturnValue_t iterate( + HealthEntry* value, + bool reset = false) override; }; -#endif /* HEALTHTABLE_H_ */ +#endif /* FSFW_HEALTH_HEALTHTABLE_H_ */ diff --git a/health/HealthTableIF.h b/health/HealthTableIF.h index 404c03e4..d61e6761 100644 --- a/health/HealthTableIF.h +++ b/health/HealthTableIF.h @@ -1,26 +1,24 @@ -#ifndef HEALTHTABLEIF_H_ -#define HEALTHTABLEIF_H_ +#ifndef FSFW_HEALTH_HEALTHTABLEIF_H_ +#define FSFW_HEALTH_HEALTHTABLEIF_H_ #include "ManagesHealthIF.h" #include "../objectmanager/ObjectManagerIF.h" #include "../returnvalues/HasReturnvaluesIF.h" -#include - class HealthTableIF: public ManagesHealthIF { - friend class HealthCommandingService; public: - virtual ~HealthTableIF() { - } + virtual ~HealthTableIF() {} virtual ReturnValue_t registerObject(object_id_t object, HasHealthIF::HealthState initilialState = HasHealthIF::HEALTHY) = 0; - virtual uint32_t getPrintSize() = 0; + virtual size_t getPrintSize() = 0; virtual void printAll(uint8_t *pointer, size_t maxSize) = 0; protected: - virtual ReturnValue_t iterate(std::pair *value, bool reset = false) = 0; + virtual ReturnValue_t iterate( + std::pair *value, + bool reset = false) = 0; }; -#endif /* HEALTHTABLEIF_H_ */ +#endif /* FRAMEWORK_HEALTH_HEALTHTABLEIF_H_ */ diff --git a/health/ManagesHealthIF.h b/health/ManagesHealthIF.h index 42d4c4f0..2edfceca 100644 --- a/health/ManagesHealthIF.h +++ b/health/ManagesHealthIF.h @@ -1,8 +1,9 @@ -#ifndef FRAMEWORK_HEALTH_MANAGESHEALTHIF_H_ -#define FRAMEWORK_HEALTH_MANAGESHEALTHIF_H_ +#ifndef FSFW_HEALTH_MANAGESHEALTHIF_H_ +#define FSFW_HEALTH_MANAGESHEALTHIF_H_ #include "HasHealthIF.h" #include "../objectmanager/ObjectManagerIF.h" + class ManagesHealthIF { public: virtual ~ManagesHealthIF() { @@ -49,4 +50,4 @@ public: } }; -#endif /* FRAMEWORK_HEALTH_MANAGESHEALTHIF_H_ */ +#endif /* FSFW_HEALTH_MANAGESHEALTHIF_H_ */ From a5cf510ae9d90b79499e0355861adbb49eaf7191 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 30 Oct 2020 13:31:07 +0100 Subject: [PATCH 21/26] host osal fixes --- osal/host/QueueFactory.cpp | 7 ++++++- timemanager/CCSDSTime.cpp | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/osal/host/QueueFactory.cpp b/osal/host/QueueFactory.cpp index da3fea55..1a679c96 100644 --- a/osal/host/QueueFactory.cpp +++ b/osal/host/QueueFactory.cpp @@ -1,6 +1,11 @@ + +#include "MessageQueue.h" + +#include "../../ipc/MessageQueueSenderIF.h" +#include "../../ipc/MessageQueueMessageIF.h" #include "../../ipc/QueueFactory.h" -#include "../../osal/host/MessageQueue.h" #include "../../serviceinterface/ServiceInterfaceStream.h" + #include QueueFactory* QueueFactory::factoryInstance = nullptr; diff --git a/timemanager/CCSDSTime.cpp b/timemanager/CCSDSTime.cpp index f99f8fbb..f137e030 100644 --- a/timemanager/CCSDSTime.cpp +++ b/timemanager/CCSDSTime.cpp @@ -1,8 +1,9 @@ -#include "../timemanager/CCSDSTime.h" +#include "CCSDSTime.h" + #include #include #include - +#include CCSDSTime::CCSDSTime() { } @@ -158,15 +159,16 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* } // 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. -#ifdef NEWLIB_NANO_NO_C99_IO +#if FSFW_NO_C99_IO == 1 uint16_t year; uint16_t month; uint16_t day; uint16_t hour; uint16_t minute; float second; - int count = sscanf((char *) from, "%4" SCNu16 "-%2" SCNu16 "-%2" SCNu16 "T%2" SCNu16 ":%2" SCNu16 ":%fZ", &year, - &month, &day, &hour, &minute, &second); + int count = sscanf((char *) from, "%4" SCNu16 "-%2" SCNu16 "-%2" SCNu16 "T%" + "2" SCNu16 ":%2" SCNu16 ":%fZ", &year, &month, &day, &hour, + &minute, &second); if (count == 6) { to->year = year; to->month = month; @@ -179,12 +181,13 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* } // try Code B (yyyy-ddd) - count = sscanf((char *) from, "%4" SCNu16 "-%3" SCNu16 "T%2" SCNu16 ":%2" SCNu16 ":%fZ", &year, &day, - &hour, &minute, &second); + count = sscanf((char *) from, "%4" SCNu16 "-%3" SCNu16 "T%2" SCNu16 ":%" + "2" SCNu16 ":%fZ", &year, &day, &hour, &minute, &second); if (count == 5) { uint8_t tempDay; ReturnValue_t result = CCSDSTime::convertDaysOfYear(day, year, - reinterpret_cast(&month), reinterpret_cast(&tempDay)); + reinterpret_cast(&month), + reinterpret_cast(&tempDay)); if (result != RETURN_OK) { return RETURN_FAILED; } From 82a2f3ec617df97d04761e7788866759a7ac5203 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 30 Oct 2020 14:21:31 +0100 Subject: [PATCH 22/26] testcfg fix --- unittest/testcfg/Makefile-FSFW-Tests | 2 +- unittest/testcfg/cdatapool/dataPoolInit.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unittest/testcfg/Makefile-FSFW-Tests b/unittest/testcfg/Makefile-FSFW-Tests index d43a6edc..2017d2bd 100644 --- a/unittest/testcfg/Makefile-FSFW-Tests +++ b/unittest/testcfg/Makefile-FSFW-Tests @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------- -# Makefile for FSFW Test +# Makefile for FSFW Test #------------------------------------------------------------------------------- # User-modifiable options #------------------------------------------------------------------------------- diff --git a/unittest/testcfg/cdatapool/dataPoolInit.h b/unittest/testcfg/cdatapool/dataPoolInit.h index 23a3d01f..9425d767 100644 --- a/unittest/testcfg/cdatapool/dataPoolInit.h +++ b/unittest/testcfg/cdatapool/dataPoolInit.h @@ -1,7 +1,7 @@ #ifndef HOSTED_CONFIG_CDATAPOOL_DATAPOOLINIT_H_ #define HOSTED_CONFIG_CDATAPOOL_DATAPOOLINIT_H_ -#include +#include #include #include #include From 5d0f96c3a14023dc9b714d0a75fdad8a91e77477 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 30 Oct 2020 14:42:42 +0100 Subject: [PATCH 23/26] reamde update --- unittest/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/unittest/README.md b/unittest/README.md index e628d43e..8a787c07 100644 --- a/unittest/README.md +++ b/unittest/README.md @@ -7,6 +7,16 @@ The makefile with default settings creates the unit test binary which can be run in the terminal or in eclipse. ### Instructions + +To run the fsfw unittests in the project, perform following steps: + +1. Copy the testcfg folder the project root (folder containing the FSFW). +2. There is a makefile inside the testcfg folder which can be used to have + a starting point to compile the unit tests. Copy that Makefile to the project + root +3. Create a folder named catch2 (can have other name which requires Makefile + adaption) and copy the Catch2 header files there (NOTE: CMake support + not enabled yet!) ### Eclipse CDT settings From 963c333365206a8c61233b742c78935b8f49c684 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 2 Nov 2020 14:45:10 +0100 Subject: [PATCH 24/26] cast added --- returnvalues/HasReturnvaluesIF.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/returnvalues/HasReturnvaluesIF.h b/returnvalues/HasReturnvaluesIF.h index a39ac742..4a3835b6 100644 --- a/returnvalues/HasReturnvaluesIF.h +++ b/returnvalues/HasReturnvaluesIF.h @@ -24,7 +24,7 @@ public: */ static constexpr ReturnValue_t makeReturnCode(uint8_t interfaceId, uint8_t number) { - return (interfaceId << 8) + number; + return (static_cast(interfaceId) << 8) + number; } }; From 77fd2cb871dcedec159bf1ae6b7014362c26814f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 2 Nov 2020 14:53:44 +0100 Subject: [PATCH 25/26] mission timestmap size is uint8 now --- defaultcfg/config/FSFWConfig.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/defaultcfg/config/FSFWConfig.h b/defaultcfg/config/FSFWConfig.h index ea724a64..ea86152c 100644 --- a/defaultcfg/config/FSFWConfig.h +++ b/defaultcfg/config/FSFWConfig.h @@ -12,10 +12,6 @@ //! Be careful, this also turns off most diagnostic prinouts! #define FSFW_REDUCED_PRINTOUT 0 -//! Default timestamp size. The default timestamp will be an eight byte CDC -//! short timestamp. -#define FSFW_MISSION_TIMESTAMP_SIZE 8 - //! Can be used to enable debugging printouts for developing the FSFW #define FSFW_DEBUGGING 0 @@ -45,6 +41,10 @@ #define FSFW_NO_C99_IO 1 namespace fsfwconfig { +//! Default timestamp size. The default timestamp will be an eight byte CDC +//! short timestamp. +static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 8; + //! 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; From a7bc69b0ac512b00a5c96f0d1116243344de3084 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 2 Nov 2020 15:00:01 +0100 Subject: [PATCH 26/26] health table update --- health/HealthTable.cpp | 19 ++++++++++++------- health/HealthTable.h | 5 +++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/health/HealthTable.cpp b/health/HealthTable.cpp index 6d6fe017..2b8b6712 100644 --- a/health/HealthTable.cpp +++ b/health/HealthTable.cpp @@ -10,6 +10,12 @@ HealthTable::HealthTable(object_id_t objectid) : mapIterator = healthMap.begin(); } +void HealthTable::setMutexTimeout(MutexIF::TimeoutType timeoutType, + uint32_t timeoutMs) { + this->timeoutType = timeoutType; + this->mutexTimeoutMs = timeoutMs; +} + HealthTable::~HealthTable() { MutexFactory::instance()->deleteMutex(mutex); } @@ -25,7 +31,7 @@ ReturnValue_t HealthTable::registerObject(object_id_t object, void HealthTable::setHealth(object_id_t object, HasHealthIF::HealthState newState) { - MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); + MutexHelper(mutex, timeoutType, mutexTimeoutMs); HealthMap::iterator iter = healthMap.find(object); if (iter != healthMap.end()) { iter->second = newState; @@ -34,7 +40,7 @@ void HealthTable::setHealth(object_id_t object, HasHealthIF::HealthState HealthTable::getHealth(object_id_t object) { HasHealthIF::HealthState state = HasHealthIF::HEALTHY; - MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); + MutexHelper(mutex, timeoutType, mutexTimeoutMs); HealthMap::iterator iter = healthMap.find(object); if (iter != healthMap.end()) { state = iter->second; @@ -42,9 +48,8 @@ HasHealthIF::HealthState HealthTable::getHealth(object_id_t object) { return state; } - bool HealthTable::hasHealth(object_id_t object) { - MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); + MutexHelper(mutex, timeoutType, mutexTimeoutMs); HealthMap::iterator iter = healthMap.find(object); if (iter != healthMap.end()) { return true; @@ -53,14 +58,14 @@ bool HealthTable::hasHealth(object_id_t object) { } size_t HealthTable::getPrintSize() { - MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); + MutexHelper(mutex, timeoutType, mutexTimeoutMs); uint32_t size = healthMap.size() * sizeof(object_id_t) + sizeof(HasHealthIF::HealthState) + sizeof(uint16_t); return size; } void HealthTable::printAll(uint8_t* pointer, size_t maxSize) { - MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); + MutexHelper(mutex, timeoutType, mutexTimeoutMs); size_t size = 0; uint16_t count = healthMap.size(); SerializeAdapter::serialize(&count, @@ -76,7 +81,7 @@ void HealthTable::printAll(uint8_t* pointer, size_t maxSize) { ReturnValue_t HealthTable::iterate(HealthEntry *value, bool reset) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); + MutexHelper(mutex, timeoutType, mutexTimeoutMs); if (reset) { mapIterator = healthMap.begin(); } diff --git a/health/HealthTable.h b/health/HealthTable.h index 945fb2e6..cea34f68 100644 --- a/health/HealthTable.h +++ b/health/HealthTable.h @@ -12,6 +12,8 @@ public: HealthTable(object_id_t objectid); virtual ~HealthTable(); + void setMutexTimeout(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs); + /** HealthTableIF overrides */ virtual ReturnValue_t registerObject(object_id_t object, HasHealthIF::HealthState initilialState = @@ -30,6 +32,9 @@ protected: using HealthEntry = std::pair; MutexIF* mutex; + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t mutexTimeoutMs = 20; + HealthMap healthMap; HealthMap::iterator mapIterator;