From 3356ccc9d4bbbe336249b2fb4763adcaea0acd52 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 22 Apr 2021 17:45:46 +0200 Subject: [PATCH 01/21] tested new comment export string for retvals --- ipc/MessageQueueIF.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipc/MessageQueueIF.h b/ipc/MessageQueueIF.h index 74ccb29a2..217174f6d 100644 --- a/ipc/MessageQueueIF.h +++ b/ipc/MessageQueueIF.h @@ -22,11 +22,11 @@ public: static const uint8_t INTERFACE_ID = CLASS_ID::MESSAGE_QUEUE_IF; //! No new messages on the queue static const ReturnValue_t EMPTY = MAKE_RETURN_CODE(1); - //! No space left for more messages + //! [EXPORT] : [COMMENT] No space left for more messages static const ReturnValue_t FULL = MAKE_RETURN_CODE(2); - //! Returned if a reply method was called without partner + //! [EXPORT] : [COMMENT] Returned if a reply method was called without partner static const ReturnValue_t NO_REPLY_PARTNER = MAKE_RETURN_CODE(3); - //! Returned if the target destination is invalid. + //! [EXPORT] : [COMMENT] Returned if the target destination is invalid. static constexpr ReturnValue_t DESTINATION_INVALID = MAKE_RETURN_CODE(4); virtual ~MessageQueueIF() {} From 7f1cbaef23d2c508e0bf88b190cb57eefd361e3e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 22 Apr 2021 18:09:23 +0200 Subject: [PATCH 02/21] updated default cmakelists --- defaultcfg/fsfwconfig/CMakeLists.txt | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/defaultcfg/fsfwconfig/CMakeLists.txt b/defaultcfg/fsfwconfig/CMakeLists.txt index cbd4ecdec..178fc2735 100644 --- a/defaultcfg/fsfwconfig/CMakeLists.txt +++ b/defaultcfg/fsfwconfig/CMakeLists.txt @@ -1,15 +1,23 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - ipc/missionMessageTypes.cpp - objects/FsfwFactory.cpp - pollingsequence/PollingSequenceFactory.cpp -) - -# Should be added to include path target_include_directories(${TARGET_NAME} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} ) -if(NOT FSFW_CONFIG_PATH) - set(FSFW_CONFIG_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +target_sources(${TARGET_NAME} PRIVATE + ipc/missionMessageTypes.cpp + pollingsequence/PollingSequenceFactory.cpp + objects/FsfwFactory.cpp +) + +# If a special translation file for object IDs exists, compile it. +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp") + target_sources(${TARGET_NAME} PRIVATE + objects/translateObjects.cpp + ) endif() +# If a special translation file for events exists, compile it. +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp") + target_sources(${TARGET_NAME} PRIVATE + events/translateEvents.cpp + ) +endif() From 413ff0d1b9f0a0ed172ff1b427aab8f3f8d40a16 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 26 Apr 2021 14:17:57 +0200 Subject: [PATCH 03/21] parameter wrapper bugfix --- parameters/ParameterHelper.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/parameters/ParameterHelper.cpp b/parameters/ParameterHelper.cpp index 24d0b2b1f..e80c2c47f 100644 --- a/parameters/ParameterHelper.cpp +++ b/parameters/ParameterHelper.cpp @@ -65,6 +65,9 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) { ParameterWrapper ownerWrapper; result = owner->getParameter(domain, uniqueIdentifier, &ownerWrapper, &streamWrapper, linearIndex); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } result = ownerWrapper.copyFrom(&streamWrapper, linearIndex); if (result != HasReturnvaluesIF::RETURN_OK) { From 097244bf8b429d1b107343a3dbd77fa537a9c86d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 29 Apr 2021 19:51:38 +0200 Subject: [PATCH 04/21] use timestamp size from FSFWConfig.h --- timemanager/TimeStamperIF.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/timemanager/TimeStamperIF.h b/timemanager/TimeStamperIF.h index 57b7f0149..534cc734f 100644 --- a/timemanager/TimeStamperIF.h +++ b/timemanager/TimeStamperIF.h @@ -2,6 +2,7 @@ #define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ #include "../returnvalues/HasReturnvaluesIF.h" +#include /** * A class implementing this IF provides facilities to add a time stamp to the @@ -16,8 +17,7 @@ public: //! This is a mission-specific constant and determines the total //! size reserved for timestamps. - //! TODO: Default define in FSFWConfig ? - static const uint8_t MISSION_TIMESTAMP_SIZE = 8; + static const uint8_t MISSION_TIMESTAMP_SIZE = fsfwconfig::FSFW_MISSION_TIMESTAMP_SIZE; virtual ReturnValue_t addTimeStamp(uint8_t* buffer, const uint8_t maxSize) = 0; virtual ~TimeStamperIF() {} From 126def219b30b1ca97c8fbc03825ed139e2a56ec Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 5 May 2021 12:59:42 +0200 Subject: [PATCH 05/21] continued tmtc server and bridge --- osal/common/CMakeLists.txt | 1 + osal/common/TcpTmTcBridge.cpp | 57 ++++++++++++ osal/common/TcpTmTcBridge.h | 54 +++++++++++ osal/common/TcpTmTcServer.cpp | 152 +++++++++++++++++++++++-------- osal/common/TcpTmTcServer.h | 26 +++++- osal/common/UdpTcPollingTask.cpp | 4 +- osal/common/UdpTcPollingTask.h | 8 +- osal/common/UdpTmTcBridge.cpp | 21 ++--- osal/common/UdpTmTcBridge.h | 6 +- osal/common/tcpipCommon.cpp | 3 + osal/common/tcpipCommon.h | 3 +- 11 files changed, 270 insertions(+), 65 deletions(-) create mode 100644 osal/common/TcpTmTcBridge.cpp create mode 100644 osal/common/TcpTmTcBridge.h diff --git a/osal/common/CMakeLists.txt b/osal/common/CMakeLists.txt index af76484d3..b7c8c033a 100644 --- a/osal/common/CMakeLists.txt +++ b/osal/common/CMakeLists.txt @@ -5,6 +5,7 @@ if(DEFINED WIN32 OR DEFINED UNIX) UdpTcPollingTask.cpp UdpTmTcBridge.cpp TcpTmTcServer.cpp + TcpTmTcBridge.cpp ) endif() diff --git a/osal/common/TcpTmTcBridge.cpp b/osal/common/TcpTmTcBridge.cpp new file mode 100644 index 000000000..a88b68e96 --- /dev/null +++ b/osal/common/TcpTmTcBridge.cpp @@ -0,0 +1,57 @@ +#include "TcpTmTcBridge.h" +#include "tcpipHelpers.h" + +#include +#include +#include + +#ifdef _WIN32 + +#include + +#elif defined(__unix__) + +#include +#include + +#endif + +const std::string TcpTmTcBridge::DEFAULT_UDP_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT; + +TcpTmTcBridge::TcpTmTcBridge(object_id_t objectId, object_id_t tcDestination, + object_id_t tmStoreId, object_id_t tcStoreId): + TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { + mutex = MutexFactory::instance()->createMutex(); + communicationLinkUp = false; +} + +ReturnValue_t TcpTmTcBridge::initialize() { + ReturnValue_t result = TmTcBridge::initialize(); + if(result != HasReturnvaluesIF::RETURN_OK) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "TmTcUdpBridge::initialize: TmTcBridge initialization failed!" + << std::endl; +#endif + return result; + } + + return HasReturnvaluesIF::RETURN_OK; +} + +TcpTmTcBridge::~TcpTmTcBridge() { + if(mutex != nullptr) { + MutexFactory::instance()->deleteMutex(mutex); + } +} + +ReturnValue_t TcpTmTcBridge::sendTm(const uint8_t *data, size_t dataLen) { + + return HasReturnvaluesIF::RETURN_OK; +} + + +void TcpTmTcBridge::setMutexProperties(MutexIF::TimeoutType timeoutType, + dur_millis_t timeoutMs) { + this->timeoutType = timeoutType; + this->mutexTimeoutMs = timeoutMs; +} diff --git a/osal/common/TcpTmTcBridge.h b/osal/common/TcpTmTcBridge.h new file mode 100644 index 000000000..db45fca89 --- /dev/null +++ b/osal/common/TcpTmTcBridge.h @@ -0,0 +1,54 @@ +#ifndef FSFW_OSAL_COMMON_TCPTMTCBRIDGE_H_ +#define FSFW_OSAL_COMMON_TCPTMTCBRIDGE_H_ + +#include "TcpIpBase.h" +#include "../../tmtcservices/TmTcBridge.h" + +#ifdef _WIN32 + +#include + +#elif defined(__unix__) + +#include + +#endif + +#include + +/** + * @brief This class should be used with the UdpTcPollingTask to implement a UDP server + * for receiving and sending PUS TMTC. + */ +class TcpTmTcBridge: + public TmTcBridge { + //friend class UdpTcPollingTask; +public: + /* The ports chosen here should not be used by any other process. */ + static const std::string DEFAULT_UDP_SERVER_PORT; + + TcpTmTcBridge(object_id_t objectId, object_id_t tcDestination, + object_id_t tmStoreId = objects::TM_STORE, + object_id_t tcStoreId = objects::TC_STORE); + virtual~ TcpTmTcBridge(); + + /** + * Set properties of internal mutex. + */ + void setMutexProperties(MutexIF::TimeoutType timeoutType, dur_millis_t timeoutMs); + + ReturnValue_t initialize() override; + +protected: + virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) override; + +private: + + //! Access to the client address is mutex protected as it is set by another task. + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + dur_millis_t mutexTimeoutMs = 20; + MutexIF* mutex; +}; + +#endif /* FSFW_OSAL_COMMON_TCPTMTCBRIDGE_H_ */ + diff --git a/osal/common/TcpTmTcServer.cpp b/osal/common/TcpTmTcServer.cpp index 08a62ffb9..8717783e7 100644 --- a/osal/common/TcpTmTcServer.cpp +++ b/osal/common/TcpTmTcServer.cpp @@ -1,6 +1,12 @@ #include "TcpTmTcServer.h" +#include "TcpTmTcBridge.h" #include "tcpipHelpers.h" + +#include "../../container/SharedRingBuffer.h" +#include "../../ipc/MessageQueueSenderIF.h" +#include "../../objectmanager/ObjectManagerIF.h" #include "../../serviceinterface/ServiceInterface.h" +#include "../../tmtcservices/TmTcMessage.h" #ifdef _WIN32 #include @@ -12,12 +18,17 @@ #endif -const std::string TcpTmTcServer::DEFAULT_TCP_SERVER_PORT = "7301"; -const std::string TcpTmTcServer::DEFAULT_TCP_CLIENT_PORT = "7302"; +#ifndef FSFW_TCP_RECV_WIRETAPPING_ENABLED +#define FSFW_TCP_RECV_WIRETAPPING_ENABLED 0 +#endif -TcpTmTcServer::TcpTmTcServer(object_id_t objectId, object_id_t tmtcUnixUdpBridge, +const std::string TcpTmTcServer::DEFAULT_TCP_SERVER_PORT = "7301"; + +TcpTmTcServer::TcpTmTcServer(object_id_t objectId, object_id_t tmtcTcpBridge, + /*SharedRingBuffer* tcpRingBuffer, */ size_t receptionBufferSize, std::string customTcpServerPort): - SystemObject(objectId), tcpPort(customTcpServerPort) { + SystemObject(objectId), tmtcBridgeId(tmtcTcpBridge), tcpPort(customTcpServerPort), + receptionBuffer(receptionBufferSize) /*, tcpRingBuffer(tcpRingBuffer) */ { if(tcpPort == "") { tcpPort = DEFAULT_TCP_SERVER_PORT; } @@ -26,11 +37,34 @@ TcpTmTcServer::TcpTmTcServer(object_id_t objectId, object_id_t tmtcUnixUdpBridge ReturnValue_t TcpTmTcServer::initialize() { using namespace tcpip; + /* + if(tcpRingBuffer == nullptr) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "TcpTmTcServer::initialize: Invalid ring buffer!" << std::endl; +#else + sif::printError("TcpTmTcServer::initialize: Invalid ring buffer!\n"); +#endif + return ObjectManagerIF::CHILD_INIT_FAILED; + } + */ + ReturnValue_t result = TcpIpBase::initialize(); if(result != HasReturnvaluesIF::RETURN_OK) { return result; } + tcStore = objectManager->get(objects::TC_STORE); + if (tcStore == nullptr) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "TcpTmTcServer::initialize: TC store uninitialized!" << std::endl; +#else + sif::printError("TcpTmTcServer::initialize: TC store uninitialized!\n"); +#endif + return ObjectManagerIF::CHILD_INIT_FAILED; + } + + tmtcBridge = objectManager->get(tmtcBridgeId); + int retval = 0; struct addrinfo *addrResult = nullptr; struct addrinfo hints = {}; @@ -42,10 +76,6 @@ ReturnValue_t TcpTmTcServer::initialize() { retval = getaddrinfo(nullptr, tcpPort.c_str(), &hints, &addrResult); if (retval != 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TcWinTcpServer::TcpTmTcServer: Retrieving address info failed!" << - std::endl; -#endif handleError(Protocol::TCP, ErrorSources::GETADDRINFO_CALL); return HasReturnvaluesIF::RETURN_FAILED; } @@ -54,9 +84,6 @@ ReturnValue_t TcpTmTcServer::initialize() { listenerTcpSocket = socket(addrResult->ai_family, addrResult->ai_socktype, addrResult->ai_protocol); if(listenerTcpSocket == INVALID_SOCKET) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TcWinTcpServer::TcWinTcpServer: Socket creation failed!" << std::endl; -#endif freeaddrinfo(addrResult); handleError(Protocol::TCP, ErrorSources::SOCKET_CALL); return HasReturnvaluesIF::RETURN_FAILED; @@ -64,10 +91,6 @@ ReturnValue_t TcpTmTcServer::initialize() { retval = bind(listenerTcpSocket, addrResult->ai_addr, static_cast(addrResult->ai_addrlen)); if(retval == SOCKET_ERROR) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TcWinTcpServer::TcpTmTcServer: Binding socket failed!" << - std::endl; -#endif freeaddrinfo(addrResult); handleError(Protocol::TCP, ErrorSources::BIND_CALL); return HasReturnvaluesIF::RETURN_FAILED; @@ -85,7 +108,7 @@ TcpTmTcServer::~TcpTmTcServer() { ReturnValue_t TcpTmTcServer::performOperation(uint8_t opCode) { using namespace tcpip; /* If a connection is accepted, the corresponding socket will be assigned to the new socket */ - socket_t clientSocket = 0; + socket_t connSocket = 0; sockaddr clientSockAddr = {}; socklen_t connectorSockAddrLen = 0; int retval = 0; @@ -98,35 +121,92 @@ ReturnValue_t TcpTmTcServer::performOperation(uint8_t opCode) { continue; } - clientSocket = accept(listenerTcpSocket, &clientSockAddr, &connectorSockAddrLen); + connSocket = accept(listenerTcpSocket, &clientSockAddr, &connectorSockAddrLen); - if(clientSocket == INVALID_SOCKET) { + if(connSocket == INVALID_SOCKET) { handleError(Protocol::TCP, ErrorSources::ACCEPT_CALL, 500); - closeSocket(clientSocket); + closeSocket(connSocket); continue; }; - retval = recv(clientSocket, reinterpret_cast(receptionBuffer.data()), - receptionBuffer.size(), 0); - if(retval > 0) { -#if FSFW_TCP_RCV_WIRETAPPING_ENABLED == 1 - sif::info << "TcpTmTcServer::performOperation: Received " << retval << " bytes." - std::endl; -#endif - handleError(Protocol::TCP, ErrorSources::RECV_CALL, 500); - } - else if(retval == 0) { - - } - else { - - } + handleServerOperation(connSocket); /* Done, shut down connection */ - retval = shutdown(clientSocket, SHUT_SEND); - closeSocket(clientSocket); + retval = shutdown(connSocket, SHUT_SEND); + if(retval != 0) { + handleError(Protocol::TCP, ErrorSources::SHUTDOWN_CALL); + } + closeSocket(connSocket); } return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t TcpTmTcServer::initializeAfterTaskCreation() { + /* Initialize the destination after task creation. This ensures + that the destination has already been set in the TMTC bridge. */ + targetTcDestination = tmtcBridge->getRequestQueue(); +// +// if(tcpRingBuffer != nullptr) { +// auto fifoCheck = tcpRingBuffer->getReceiveSizesFIFO(); +// if (fifoCheck == nullptr) { +//#if FSFW_CPP_OSTREAM_ENABLED == 1 +// sif::error << "TcpTmTcServer::initializeAfterTaskCreation: " +// "TCP ring buffer does not have a FIFO!" << std::endl; +//#else +// sif::printError("TcpTmTcServer::initialize: TCP ring buffer does not have a FIFO!\n"); +//#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */ +// } +// } + + return HasReturnvaluesIF::RETURN_OK; +} + +void TcpTmTcServer::handleServerOperation(socket_t connSocket) { + int retval = 0; + do { + retval = recv(connSocket, + reinterpret_cast(receptionBuffer.data()), + receptionBuffer.capacity(), + tcpFlags); + if (retval > 0) { + handleTcReception(retval); + } + else if(retval == 0) { + /* Client has finished sending telecommands, send telemetry now */ + } + else { + /* Should not happen */ + } + } while(retval > 0); +} + +ReturnValue_t TcpTmTcServer::handleTcReception(size_t bytesRecvd) { +#if FSFW_TCP_RECV_WIRETAPPING_ENABLED == 1 + arrayprinter::print(receptionBuffer.data(), bytesRead); +#endif + store_address_t storeId; + ReturnValue_t result = tcStore->addData(&storeId, receptionBuffer.data(), bytesRecvd); + if (result != HasReturnvaluesIF::RETURN_OK) { +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning<< "TcpTmTcServer::handleServerOperation: Data storage failed." << std::endl; + sif::warning << "Packet size: " << bytesRecvd << std::endl; +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ +#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + } + + TmTcMessage message(storeId); + + result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); + if (result != HasReturnvaluesIF::RETURN_OK) { +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "UdpTcPollingTask::handleSuccessfullTcRead: " + " Sending message to queue failed" << std::endl; +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ +#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + tcStore->deleteData(storeId); + } + return result; +} diff --git a/osal/common/TcpTmTcServer.h b/osal/common/TcpTmTcServer.h index 4dcc77a2d..6db6621d4 100644 --- a/osal/common/TcpTmTcServer.h +++ b/osal/common/TcpTmTcServer.h @@ -2,7 +2,11 @@ #define FSFW_OSAL_WINDOWS_TCWINTCPSERVER_H_ #include "TcpIpBase.h" +#include "../../ipc/messageQueueDefinitions.h" +#include "../../ipc/MessageQueueIF.h" +#include "../../objectmanager/frameworkObjects.h" #include "../../objectmanager/SystemObject.h" +#include "../../storagemanager/StorageManagerIF.h" #include "../../tasks/ExecutableObjectIF.h" #ifdef __unix__ @@ -12,8 +16,9 @@ #include #include -//! Debugging preprocessor define. -#define FSFW_TCP_RCV_WIRETAPPING_ENABLED 0 +class TcpTmTcBridge; +//class SharedRingBuffer; + /** * @brief Windows TCP server used to receive telecommands on a Windows Host @@ -28,26 +33,39 @@ public: /* The ports chosen here should not be used by any other process. */ static const std::string DEFAULT_TCP_SERVER_PORT; static const std::string DEFAULT_TCP_CLIENT_PORT; + static constexpr size_t ETHERNET_MTU_SIZE = 1500; - TcpTmTcServer(object_id_t objectId, object_id_t tmtcUnixUdpBridge, + TcpTmTcServer(object_id_t objectId, object_id_t tmtcTcpBridge /*, SharedRingBuffer* tcpRingBuffer*/, + size_t receptionBufferSize = ETHERNET_MTU_SIZE, std::string customTcpServerPort = ""); virtual~ TcpTmTcServer(); ReturnValue_t initialize() override; ReturnValue_t performOperation(uint8_t opCode) override; + ReturnValue_t initializeAfterTaskCreation() override; + +protected: + StorageManagerIF* tcStore = nullptr; private: + //! TMTC bridge is cached. + object_id_t tmtcBridgeId = objects::NO_OBJECT; + TcpTmTcBridge* tmtcBridge = nullptr; std::string tcpPort; + int tcpFlags = 0; socket_t listenerTcpSocket = 0; struct sockaddr tcpAddress; + MessageQueueId_t targetTcDestination = MessageQueueIF::NO_QUEUE; int tcpAddrLen = sizeof(tcpAddress); int currentBacklog = 3; std::vector receptionBuffer; + //SharedRingBuffer* tcpRingBuffer; int tcpSockOpt = 0; - + void handleServerOperation(socket_t connSocket); + ReturnValue_t handleTcReception(size_t bytesRecvd); }; #endif /* FSFW_OSAL_WINDOWS_TCWINTCPSERVER_H_ */ diff --git a/osal/common/UdpTcPollingTask.cpp b/osal/common/UdpTcPollingTask.cpp index 47f67b295..d79e24479 100644 --- a/osal/common/UdpTcPollingTask.cpp +++ b/osal/common/UdpTcPollingTask.cpp @@ -18,9 +18,9 @@ #define FSFW_UDP_RECV_WIRETAPPING_ENABLED 0 UdpTcPollingTask::UdpTcPollingTask(object_id_t objectId, - object_id_t tmtcUnixUdpBridge, size_t maxRecvSize, + object_id_t tmtcUdpBridge, size_t maxRecvSize, double timeoutSeconds): SystemObject(objectId), - tmtcBridgeId(tmtcUnixUdpBridge) { + tmtcBridgeId(tmtcUdpBridge) { if(frameSize > 0) { this->frameSize = frameSize; } diff --git a/osal/common/UdpTcPollingTask.h b/osal/common/UdpTcPollingTask.h index 052eced52..cfe74b346 100644 --- a/osal/common/UdpTcPollingTask.h +++ b/osal/common/UdpTcPollingTask.h @@ -1,5 +1,5 @@ -#ifndef FSFW_OSAL_WINDOWS_TCSOCKETPOLLINGTASK_H_ -#define FSFW_OSAL_WINDOWS_TCSOCKETPOLLINGTASK_H_ +#ifndef FSFW_OSAL_COMMON_UDPTCPOLLINGTASK_H_ +#define FSFW_OSAL_COMMON_UDPTCPOLLINGTASK_H_ #include "UdpTmTcBridge.h" #include "../../objectmanager/SystemObject.h" @@ -22,7 +22,7 @@ public: //! 0.5 default milliseconds timeout for now. static constexpr timeval DEFAULT_TIMEOUT = {0, 500}; - UdpTcPollingTask(object_id_t objectId, object_id_t tmtcUnixUdpBridge, + UdpTcPollingTask(object_id_t objectId, object_id_t tmtcUdpBridge, size_t maxRecvSize = 0, double timeoutSeconds = -1); virtual~ UdpTcPollingTask(); @@ -57,4 +57,4 @@ private: ReturnValue_t handleSuccessfullTcRead(size_t bytesRead); }; -#endif /* FRAMEWORK_OSAL_LINUX_TCSOCKETPOLLINGTASK_H_ */ +#endif /* FSFW_OSAL_COMMON_UDPTCPOLLINGTASK_H_ */ diff --git a/osal/common/UdpTmTcBridge.cpp b/osal/common/UdpTmTcBridge.cpp index ba23f521b..ccbb194e3 100644 --- a/osal/common/UdpTmTcBridge.cpp +++ b/osal/common/UdpTmTcBridge.cpp @@ -16,7 +16,9 @@ #endif //! Debugging preprocessor define. +#ifndef FSFW_UDP_SEND_WIRETAPPING_ENABLED #define FSFW_UDP_SEND_WIRETAPPING_ENABLED 0 +#endif const std::string UdpTmTcBridge::DEFAULT_UDP_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT; @@ -38,7 +40,7 @@ ReturnValue_t UdpTmTcBridge::initialize() { ReturnValue_t result = TmTcBridge::initialize(); if(result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TmTcUdpBridge::initialize: TmTcBridge initialization failed!" + sif::error << "UdpTmTcBridge::initialize: TmTcBridge initialization failed!" << std::endl; #endif return result; @@ -54,10 +56,10 @@ ReturnValue_t UdpTmTcBridge::initialize() { /* Tell the user that we could not find a usable */ /* Winsock DLL. */ #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TmTcUdpBridge::TmTcUdpBridge: WSAStartup failed with error: " << + sif::error << "UdpTmTcBridge::UdpTmTcBridge: WSAStartup failed with error: " << err << std::endl; #else - sif::printError("TmTcUdpBridge::TmTcUdpBridge: WSAStartup failed with error: %d\n", + sif::printError("UdpTmTcBridge::UdpTmTcBridge: WSAStartup failed with error: %d\n", err); #endif return HasReturnvaluesIF::RETURN_FAILED; @@ -78,19 +80,12 @@ ReturnValue_t UdpTmTcBridge::initialize() { getaddrinfo to assign the address 0.0.0.0 (any address) */ int retval = getaddrinfo(nullptr, udpServerPort.c_str(), &hints, &addrResult); if (retval != 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TmTcUdpBridge::TmTcUdpBridge: Retrieving address info failed!" << - std::endl; -#endif + tcpip::handleError(tcpip::Protocol::UDP, tcpip::ErrorSources::GETADDRINFO_CALL); return HasReturnvaluesIF::RETURN_FAILED; } serverSocket = socket(addrResult->ai_family, addrResult->ai_socktype, addrResult->ai_protocol); if(serverSocket == INVALID_SOCKET) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TmTcUdpBridge::TmTcUdpBridge: Could not open UDP socket!" << - std::endl; -#endif freeaddrinfo(addrResult); tcpip::handleError(tcpip::Protocol::UDP, tcpip::ErrorSources::SOCKET_CALL); return HasReturnvaluesIF::RETURN_FAILED; @@ -102,10 +97,6 @@ ReturnValue_t UdpTmTcBridge::initialize() { retval = bind(serverSocket, addrResult->ai_addr, static_cast(addrResult->ai_addrlen)); if(retval != 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TmTcUdpBridge::TmTcUdpBridge: Could not bind " - "local port (" << udpServerPort << ") to server socket!" << std::endl; -#endif freeaddrinfo(addrResult); tcpip::handleError(tcpip::Protocol::UDP, tcpip::ErrorSources::BIND_CALL); return HasReturnvaluesIF::RETURN_FAILED; diff --git a/osal/common/UdpTmTcBridge.h b/osal/common/UdpTmTcBridge.h index 8b8d19491..290f5eb0d 100644 --- a/osal/common/UdpTmTcBridge.h +++ b/osal/common/UdpTmTcBridge.h @@ -1,5 +1,5 @@ -#ifndef FSFW_OSAL_WINDOWS_TMTCWINUDPBRIDGE_H_ -#define FSFW_OSAL_WINDOWS_TMTCWINUDPBRIDGE_H_ +#ifndef FSFW_OSAL_COMMON_TMTCUDPBRIDGE_H_ +#define FSFW_OSAL_COMMON_TMTCUDPBRIDGE_H_ #include "TcpIpBase.h" #include "../../tmtcservices/TmTcBridge.h" @@ -56,5 +56,5 @@ private: MutexIF* mutex; }; -#endif /* FSFW_OSAL_HOST_TMTCWINUDPBRIDGE_H_ */ +#endif /* FSFW_OSAL_COMMON_TMTCUDPBRIDGE_H_ */ diff --git a/osal/common/tcpipCommon.cpp b/osal/common/tcpipCommon.cpp index 551e2a426..d4a3e8e6f 100644 --- a/osal/common/tcpipCommon.cpp +++ b/osal/common/tcpipCommon.cpp @@ -35,6 +35,9 @@ void tcpip::determineErrorStrings(Protocol protocol, ErrorSources errorSrc, std: else if(errorSrc == ErrorSources::GETADDRINFO_CALL) { srcString = "getaddrinfo call"; } + else if(errorSrc == ErrorSources::SHUTDOWN_CALL) { + srcString = "shutdown call"; + } else { srcString = "unknown call"; } diff --git a/osal/common/tcpipCommon.h b/osal/common/tcpipCommon.h index 22b914dc1..eb1bd9100 100644 --- a/osal/common/tcpipCommon.h +++ b/osal/common/tcpipCommon.h @@ -29,7 +29,8 @@ enum class ErrorSources { RECVFROM_CALL, LISTEN_CALL, ACCEPT_CALL, - SENDTO_CALL + SENDTO_CALL, + SHUTDOWN_CALL }; void determineErrorStrings(Protocol protocol, ErrorSources errorSrc, std::string& protStr, From c1d30aad13753591b57db9e549333a596b606947 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 5 May 2021 15:59:41 +0200 Subject: [PATCH 06/21] TCP server implementation finished A lot of smaller tweaks and smaller refactoring done in UDP TMTC bridge as well --- osal/common/TcpTmTcBridge.cpp | 26 ++++++++-- osal/common/TcpTmTcBridge.h | 25 ++++++++-- osal/common/TcpTmTcServer.cpp | 86 ++++++++++++++++++++-------------- osal/common/TcpTmTcServer.h | 44 ++++++++++++----- osal/common/UdpTcPollingTask.h | 7 +-- osal/common/UdpTmTcBridge.cpp | 2 +- osal/common/UdpTmTcBridge.h | 10 +++- osal/common/tcpipCommon.cpp | 6 +++ osal/common/tcpipCommon.h | 1 + tmtcservices/TmTcBridge.cpp | 7 ++- tmtcservices/TmTcBridge.h | 3 +- 11 files changed, 152 insertions(+), 65 deletions(-) diff --git a/osal/common/TcpTmTcBridge.cpp b/osal/common/TcpTmTcBridge.cpp index a88b68e96..24fab9a90 100644 --- a/osal/common/TcpTmTcBridge.cpp +++ b/osal/common/TcpTmTcBridge.cpp @@ -22,15 +22,18 @@ TcpTmTcBridge::TcpTmTcBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, object_id_t tcStoreId): TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { mutex = MutexFactory::instance()->createMutex(); - communicationLinkUp = false; + // Connection is always up, TM is requested by connecting to server and receiving packets + registerCommConnect(); } ReturnValue_t TcpTmTcBridge::initialize() { ReturnValue_t result = TmTcBridge::initialize(); if(result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TmTcUdpBridge::initialize: TmTcBridge initialization failed!" + sif::error << "TcpTmTcBridge::initialize: TmTcBridge initialization failed!" << std::endl; +#else + sif::printError("TcpTmTcBridge::initialize: TmTcBridge initialization failed!\n"); #endif return result; } @@ -44,8 +47,25 @@ TcpTmTcBridge::~TcpTmTcBridge() { } } -ReturnValue_t TcpTmTcBridge::sendTm(const uint8_t *data, size_t dataLen) { +ReturnValue_t TcpTmTcBridge::handleTm() { + // Simply store the telemetry in the FIFO, the server will use it to access the TM + MutexGuard guard(mutex, timeoutType, mutexTimeoutMs); + TmTcMessage message; + ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + for (ReturnValue_t result = tmTcReceptionQueue->receiveMessage(&message); + result == HasReturnvaluesIF::RETURN_OK; + result = tmTcReceptionQueue->receiveMessage(&message)) + { + status = storeDownlinkData(&message); + if(status != HasReturnvaluesIF::RETURN_OK) { + break; + } + } + return HasReturnvaluesIF::RETURN_OK; +} +ReturnValue_t TcpTmTcBridge::sendTm(const uint8_t *data, size_t dataLen) { + // Not used. The Server uses the FIFO to access and send the telemetry. return HasReturnvaluesIF::RETURN_OK; } diff --git a/osal/common/TcpTmTcBridge.h b/osal/common/TcpTmTcBridge.h index db45fca89..6cfacb9fa 100644 --- a/osal/common/TcpTmTcBridge.h +++ b/osal/common/TcpTmTcBridge.h @@ -17,16 +17,30 @@ #include /** - * @brief This class should be used with the UdpTcPollingTask to implement a UDP server - * for receiving and sending PUS TMTC. + * @brief This class should be used with the TcpTmTcServer to implement a TCP server + * for receiving and sending PUS telemetry and telecommands (TMTC) + * @details + * This bridge tasks takes care of filling a FIFO which generated telemetry. The TcpTmTcServer + * will take care of sending the telemetry stored in the FIFO if a client connects to the + * server. This bridge will also be the default destination for telecommands, but the telecommands + * will be relayed to a specified tcDestination directly. */ class TcpTmTcBridge: public TmTcBridge { - //friend class UdpTcPollingTask; + friend class TcpTmTcServer; public: /* The ports chosen here should not be used by any other process. */ static const std::string DEFAULT_UDP_SERVER_PORT; + /** + * Constructor + * @param objectId Object ID of the TcpTmTcBridge. + * @param tcDestination Destination for received TC packets. Any received telecommands will + * be sent there directly. The destination object needs to implement + * AcceptsTelecommandsIF. + * @param tmStoreId TM store object ID. It is recommended to the default object ID + * @param tcStoreId TC store object ID. It is recommended to the default object ID + */ TcpTmTcBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId = objects::TM_STORE, object_id_t tcStoreId = objects::TC_STORE); @@ -39,12 +53,15 @@ public: ReturnValue_t initialize() override; + protected: + ReturnValue_t handleTm() override; virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) override; private: - //! Access to the client address is mutex protected as it is set by another task. + //! Access to the FIFO needs to be mutex protected because it is used by the bridge and + //! the server. MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; dur_millis_t mutexTimeoutMs = 20; MutexIF* mutex; diff --git a/osal/common/TcpTmTcServer.cpp b/osal/common/TcpTmTcServer.cpp index 8717783e7..25403e8bd 100644 --- a/osal/common/TcpTmTcServer.cpp +++ b/osal/common/TcpTmTcServer.cpp @@ -4,6 +4,7 @@ #include "../../container/SharedRingBuffer.h" #include "../../ipc/MessageQueueSenderIF.h" +#include "../../ipc/MutexGuard.h" #include "../../objectmanager/ObjectManagerIF.h" #include "../../serviceinterface/ServiceInterface.h" #include "../../tmtcservices/TmTcMessage.h" @@ -25,10 +26,9 @@ const std::string TcpTmTcServer::DEFAULT_TCP_SERVER_PORT = "7301"; TcpTmTcServer::TcpTmTcServer(object_id_t objectId, object_id_t tmtcTcpBridge, - /*SharedRingBuffer* tcpRingBuffer, */ size_t receptionBufferSize, - std::string customTcpServerPort): - SystemObject(objectId), tmtcBridgeId(tmtcTcpBridge), tcpPort(customTcpServerPort), - receptionBuffer(receptionBufferSize) /*, tcpRingBuffer(tcpRingBuffer) */ { + size_t receptionBufferSize, std::string customTcpServerPort): + SystemObject(objectId), tmtcBridgeId(tmtcTcpBridge), + tcpPort(customTcpServerPort), receptionBuffer(receptionBufferSize) { if(tcpPort == "") { tcpPort = DEFAULT_TCP_SERVER_PORT; } @@ -37,17 +37,6 @@ TcpTmTcServer::TcpTmTcServer(object_id_t objectId, object_id_t tmtcTcpBridge, ReturnValue_t TcpTmTcServer::initialize() { using namespace tcpip; - /* - if(tcpRingBuffer == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TcpTmTcServer::initialize: Invalid ring buffer!" << std::endl; -#else - sif::printError("TcpTmTcServer::initialize: Invalid ring buffer!\n"); -#endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } - */ - ReturnValue_t result = TcpIpBase::initialize(); if(result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -74,13 +63,14 @@ ReturnValue_t TcpTmTcServer::initialize() { hints.ai_protocol = IPPROTO_TCP; hints.ai_flags = AI_PASSIVE; + // Listen to all addresses (0.0.0.0) by using AI_PASSIVE in the hint flags retval = getaddrinfo(nullptr, tcpPort.c_str(), &hints, &addrResult); if (retval != 0) { handleError(Protocol::TCP, ErrorSources::GETADDRINFO_CALL); return HasReturnvaluesIF::RETURN_FAILED; } - /* Open TCP (stream) socket */ + // Open TCP (stream) socket listenerTcpSocket = socket(addrResult->ai_family, addrResult->ai_socktype, addrResult->ai_protocol); if(listenerTcpSocket == INVALID_SOCKET) { @@ -89,6 +79,7 @@ ReturnValue_t TcpTmTcServer::initialize() { return HasReturnvaluesIF::RETURN_FAILED; } + // Bind to the address found by getaddrinfo retval = bind(listenerTcpSocket, addrResult->ai_addr, static_cast(addrResult->ai_addrlen)); if(retval == SOCKET_ERROR) { freeaddrinfo(addrResult); @@ -107,15 +98,15 @@ TcpTmTcServer::~TcpTmTcServer() { ReturnValue_t TcpTmTcServer::performOperation(uint8_t opCode) { using namespace tcpip; - /* If a connection is accepted, the corresponding socket will be assigned to the new socket */ + // If a connection is accepted, the corresponding socket will be assigned to the new socket socket_t connSocket = 0; sockaddr clientSockAddr = {}; socklen_t connectorSockAddrLen = 0; int retval = 0; - /* Listen for connection requests permanently for lifetime of program */ + // Listen for connection requests permanently for lifetime of program while(true) { - retval = listen(listenerTcpSocket, currentBacklog); + retval = listen(listenerTcpSocket, tcpBacklog); if(retval == SOCKET_ERROR) { handleError(Protocol::TCP, ErrorSources::LISTEN_CALL, 500); continue; @@ -131,7 +122,7 @@ ReturnValue_t TcpTmTcServer::performOperation(uint8_t opCode) { handleServerOperation(connSocket); - /* Done, shut down connection */ + // Done, shut down connection and go back to listening for client requests retval = shutdown(connSocket, SHUT_SEND); if(retval != 0) { handleError(Protocol::TCP, ErrorSources::SHUTDOWN_CALL); @@ -142,29 +133,21 @@ ReturnValue_t TcpTmTcServer::performOperation(uint8_t opCode) { } ReturnValue_t TcpTmTcServer::initializeAfterTaskCreation() { + if(tmtcBridge == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } /* Initialize the destination after task creation. This ensures that the destination has already been set in the TMTC bridge. */ targetTcDestination = tmtcBridge->getRequestQueue(); - -// -// if(tcpRingBuffer != nullptr) { -// auto fifoCheck = tcpRingBuffer->getReceiveSizesFIFO(); -// if (fifoCheck == nullptr) { -//#if FSFW_CPP_OSTREAM_ENABLED == 1 -// sif::error << "TcpTmTcServer::initializeAfterTaskCreation: " -// "TCP ring buffer does not have a FIFO!" << std::endl; -//#else -// sif::printError("TcpTmTcServer::initialize: TCP ring buffer does not have a FIFO!\n"); -//#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */ -// } -// } - + tcStore = tmtcBridge->tcStore; + tmStore = tmtcBridge->tmStore; return HasReturnvaluesIF::RETURN_OK; } void TcpTmTcServer::handleServerOperation(socket_t connSocket) { int retval = 0; do { + // Read all telecommands sent by the client retval = recv(connSocket, reinterpret_cast(receptionBuffer.data()), receptionBuffer.capacity(), @@ -173,10 +156,12 @@ void TcpTmTcServer::handleServerOperation(socket_t connSocket) { handleTcReception(retval); } else if(retval == 0) { - /* Client has finished sending telecommands, send telemetry now */ + // Client has finished sending telecommands, send telemetry now + handleTmSending(connSocket); } else { - /* Should not happen */ + // Should not happen + tcpip::handleError(tcpip::Protocol::TCP, tcpip::ErrorSources::RECV_CALL); } } while(retval > 0); } @@ -210,3 +195,32 @@ ReturnValue_t TcpTmTcServer::handleTcReception(size_t bytesRecvd) { } return result; } + +void TcpTmTcServer::setTcpBacklog(uint8_t tcpBacklog) { + this->tcpBacklog = tcpBacklog; +} + +ReturnValue_t TcpTmTcServer::handleTmSending(socket_t connSocket) { + // Access to the FIFO is mutex protected because it is filled by the bridge + MutexGuard(tmtcBridge->mutex, tmtcBridge->timeoutType, tmtcBridge->mutexTimeoutMs); + store_address_t storeId; + while((not tmtcBridge->tmFifo->empty()) and + (tmtcBridge->packetSentCounter < tmtcBridge->sentPacketsPerCycle)) { + tmtcBridge->tmFifo->retrieve(&storeId); + + // Using the store accessor will take care of deleting TM from the store automatically + ConstStorageAccessor storeAccessor(storeId); + ReturnValue_t result = tmStore->getData(storeId, storeAccessor); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + int retval = send(connSocket, + reinterpret_cast(storeAccessor.data()), + storeAccessor.size(), + tcpTmFlags); + if(retval != static_cast(storeAccessor.size())) { + tcpip::handleError(tcpip::Protocol::TCP, tcpip::ErrorSources::SEND_CALL); + } + } + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/osal/common/TcpTmTcServer.h b/osal/common/TcpTmTcServer.h index 6db6621d4..e43283700 100644 --- a/osal/common/TcpTmTcServer.h +++ b/osal/common/TcpTmTcServer.h @@ -1,5 +1,5 @@ -#ifndef FSFW_OSAL_WINDOWS_TCWINTCPSERVER_H_ -#define FSFW_OSAL_WINDOWS_TCWINTCPSERVER_H_ +#ifndef FSFW_OSAL_COMMON_TCP_TMTC_SERVER_H_ +#define FSFW_OSAL_COMMON_TCP_TMTC_SERVER_H_ #include "TcpIpBase.h" #include "../../ipc/messageQueueDefinitions.h" @@ -17,13 +17,22 @@ #include class TcpTmTcBridge; -//class SharedRingBuffer; - /** - * @brief Windows TCP server used to receive telecommands on a Windows Host + * @brief TCP server implementation * @details - * Based on: https://docs.microsoft.com/en-us/windows/win32/winsock/complete-server-code + * This server will run for the whole program lifetime and will take care of serving client + * requests on a specified TCP server port. This server waas written in a generic way and + * can be used on Unix and on Windows systems. + * + * If a connection is accepted, the server will read all telecommands sent by a client and then + * send all telemetry currently found in the TMTC bridge FIFO. + * + * Reading telemetry without sending telecommands is possible by connecting, shutting down the + * send operation immediately and then reading the telemetry. It is therefore recommended to + * connect to the server regularly, even if no telecommands need to be sent. + * + * The server will listen to a specific port on all addresses (0.0.0.0). */ class TcpTmTcServer: public SystemObject, @@ -35,18 +44,28 @@ public: static const std::string DEFAULT_TCP_CLIENT_PORT; static constexpr size_t ETHERNET_MTU_SIZE = 1500; - TcpTmTcServer(object_id_t objectId, object_id_t tmtcTcpBridge /*, SharedRingBuffer* tcpRingBuffer*/, - size_t receptionBufferSize = ETHERNET_MTU_SIZE, + /** + * TCP Server Constructor + * @param objectId Object ID of the TCP Server + * @param tmtcTcpBridge Object ID of the TCP TMTC Bridge object + * @param receptionBufferSize This will be the size of the reception buffer. Default buffer + * size will be the Ethernet MTU size + * @param customTcpServerPort The user can specify another port than the default (7301) here. + */ + TcpTmTcServer(object_id_t objectId, object_id_t tmtcTcpBridge, + size_t receptionBufferSize = ETHERNET_MTU_SIZE + 1, std::string customTcpServerPort = ""); virtual~ TcpTmTcServer(); + void setTcpBacklog(uint8_t tcpBacklog); + ReturnValue_t initialize() override; ReturnValue_t performOperation(uint8_t opCode) override; ReturnValue_t initializeAfterTaskCreation() override; protected: StorageManagerIF* tcStore = nullptr; - + StorageManagerIF* tmStore = nullptr; private: //! TMTC bridge is cached. object_id_t tmtcBridgeId = objects::NO_OBJECT; @@ -58,14 +77,15 @@ private: struct sockaddr tcpAddress; MessageQueueId_t targetTcDestination = MessageQueueIF::NO_QUEUE; int tcpAddrLen = sizeof(tcpAddress); - int currentBacklog = 3; + int tcpBacklog = 3; std::vector receptionBuffer; - //SharedRingBuffer* tcpRingBuffer; int tcpSockOpt = 0; + int tcpTmFlags = 0; void handleServerOperation(socket_t connSocket); ReturnValue_t handleTcReception(size_t bytesRecvd); + ReturnValue_t handleTmSending(socket_t connSocket); }; -#endif /* FSFW_OSAL_WINDOWS_TCWINTCPSERVER_H_ */ +#endif /* FSFW_OSAL_COMMON_TCP_TMTC_SERVER_H_ */ diff --git a/osal/common/UdpTcPollingTask.h b/osal/common/UdpTcPollingTask.h index cfe74b346..9a680fb81 100644 --- a/osal/common/UdpTcPollingTask.h +++ b/osal/common/UdpTcPollingTask.h @@ -9,8 +9,11 @@ #include /** - * @brief This class should be used with the UdpTmTcBridge to implement a UDP server + * @brief This class can be used with the UdpTmTcBridge to implement a UDP server * for receiving and sending PUS TMTC. + * @details + * This task is exclusively used to poll telecommands from a given socket and transfer them + * to the FSFW software bus. It used the blocking recvfrom call to do this. */ class UdpTcPollingTask: public TcpIpBase, @@ -45,8 +48,6 @@ private: object_id_t tmtcBridgeId = objects::NO_OBJECT; UdpTmTcBridge* tmtcBridge = nullptr; MessageQueueId_t targetTcDestination = MessageQueueIF::NO_QUEUE; - - //! See: https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recvfrom int receptionFlags = 0; std::vector receptionBuffer; diff --git a/osal/common/UdpTmTcBridge.cpp b/osal/common/UdpTmTcBridge.cpp index ccbb194e3..b07ca7a55 100644 --- a/osal/common/UdpTmTcBridge.cpp +++ b/osal/common/UdpTmTcBridge.cpp @@ -23,7 +23,7 @@ const std::string UdpTmTcBridge::DEFAULT_UDP_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT; UdpTmTcBridge::UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, - object_id_t tmStoreId, object_id_t tcStoreId, std::string udpServerPort): + std::string udpServerPort, object_id_t tmStoreId, object_id_t tcStoreId): TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { if(udpServerPort == "") { this->udpServerPort = DEFAULT_UDP_SERVER_PORT; diff --git a/osal/common/UdpTmTcBridge.h b/osal/common/UdpTmTcBridge.h index 290f5eb0d..74084a9d8 100644 --- a/osal/common/UdpTmTcBridge.h +++ b/osal/common/UdpTmTcBridge.h @@ -17,8 +17,13 @@ #include /** - * @brief This class should be used with the UdpTcPollingTask to implement a UDP server + * @brief This class can be used with the UdpTcPollingTask to implement a UDP server * for receiving and sending PUS TMTC. + * @details + * This bridge task will take care of sending telemetry back to a UDP client if a connection + * was established and store them in a FIFO if this was not done yet. It is also be the default + * destination for telecommands, but the telecommands will be relayed to a specified tcDestination + * directly. */ class UdpTmTcBridge: public TmTcBridge, @@ -29,7 +34,8 @@ public: static const std::string DEFAULT_UDP_SERVER_PORT; UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, - object_id_t tmStoreId, object_id_t tcStoreId, std::string udpServerPort = ""); + std::string udpServerPort = "", object_id_t tmStoreId = objects::TM_STORE, + object_id_t tcStoreId = objects::TC_STORE); virtual~ UdpTmTcBridge(); /** diff --git a/osal/common/tcpipCommon.cpp b/osal/common/tcpipCommon.cpp index d4a3e8e6f..ca4dbf180 100644 --- a/osal/common/tcpipCommon.cpp +++ b/osal/common/tcpipCommon.cpp @@ -32,6 +32,12 @@ void tcpip::determineErrorStrings(Protocol protocol, ErrorSources errorSrc, std: else if(errorSrc == ErrorSources::RECVFROM_CALL) { srcString = "recvfrom call"; } + else if(errorSrc == ErrorSources::SEND_CALL) { + srcString = "send call"; + } + else if(errorSrc == ErrorSources::SENDTO_CALL) { + srcString = "sendto call"; + } else if(errorSrc == ErrorSources::GETADDRINFO_CALL) { srcString = "getaddrinfo call"; } diff --git a/osal/common/tcpipCommon.h b/osal/common/tcpipCommon.h index eb1bd9100..ce7a90cd1 100644 --- a/osal/common/tcpipCommon.h +++ b/osal/common/tcpipCommon.h @@ -29,6 +29,7 @@ enum class ErrorSources { RECVFROM_CALL, LISTEN_CALL, ACCEPT_CALL, + SEND_CALL, SENDTO_CALL, SHUTDOWN_CALL }; diff --git a/tmtcservices/TmTcBridge.cpp b/tmtcservices/TmTcBridge.cpp index dcffac41e..1257ef890 100644 --- a/tmtcservices/TmTcBridge.cpp +++ b/tmtcservices/TmTcBridge.cpp @@ -183,8 +183,11 @@ ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage *message) { if(tmFifo->full()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "TmTcBridge::storeDownlinkData: TM downlink max. number " - << "of stored packet IDs reached! " << std::endl; + sif::warning << "TmTcBridge::storeDownlinkData: TM downlink max. number " + "of stored packet IDs reached!" << std::endl; +#else + sif::printWarning("TmTcBridge::storeDownlinkData: TM downlink max. number " + "of stored packet IDs reached!\n"); #endif if(overwriteOld) { tmFifo->retrieve(&storeId); diff --git a/tmtcservices/TmTcBridge.h b/tmtcservices/TmTcBridge.h index 0177648c0..d3e1c5471 100644 --- a/tmtcservices/TmTcBridge.h +++ b/tmtcservices/TmTcBridge.h @@ -150,8 +150,7 @@ protected: void printData(uint8_t * data, size_t dataLen); /** - * This fifo can be used to store downlink data - * which can not be sent at the moment. + * This FIFO can be used to store downlink data which can not be sent at the moment. */ DynamicFIFO* tmFifo = nullptr; uint8_t sentPacketsPerCycle = DEFAULT_STORED_DATA_SENT_PER_CYCLE; From 8b17c40aa61537a70ce947b1db8bf338dea2ae16 Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Tue, 11 May 2021 15:02:04 +0200 Subject: [PATCH 07/21] Added Network Byte Order --- serialize/SerializeIF.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/serialize/SerializeIF.h b/serialize/SerializeIF.h index d72218f0a..dfd854e3a 100644 --- a/serialize/SerializeIF.h +++ b/serialize/SerializeIF.h @@ -19,7 +19,10 @@ class SerializeIF { public: enum class Endianness : uint8_t { - BIG, LITTLE, MACHINE + BIG, + LITTLE, + MACHINE, + NETWORK = BIG // Added for convenience like htons on sockets }; static const uint8_t INTERFACE_ID = CLASS_ID::SERIALIZE_IF; From d807998f4de768be499aa3a48f9bf2d577057667 Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Tue, 11 May 2021 15:25:38 +0200 Subject: [PATCH 08/21] Added Missing includes in Host Osal Updated correct defaults for Host MessageQueues --- osal/host/MessageQueue.cpp | 2 ++ osal/host/MessageQueue.h | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/osal/host/MessageQueue.cpp b/osal/host/MessageQueue.cpp index 41c55a3df..4e2862716 100644 --- a/osal/host/MessageQueue.cpp +++ b/osal/host/MessageQueue.cpp @@ -5,6 +5,8 @@ #include "../../ipc/MutexFactory.h" #include "../../ipc/MutexGuard.h" +#include + MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize): messageSize(maxMessageSize), messageDepth(messageDepth) { queueLock = MutexFactory::instance()->createMutex(); diff --git a/osal/host/MessageQueue.h b/osal/host/MessageQueue.h index e965123dc..1c9b5e331 100644 --- a/osal/host/MessageQueue.h +++ b/osal/host/MessageQueue.h @@ -217,15 +217,15 @@ private: * @brief The class stores the queue id it got assigned. * If initialization fails, the queue id is set to zero. */ - MessageQueueId_t mqId = 0; + MessageQueueId_t mqId = MessageQueueIF::NO_QUEUE; size_t messageSize = 0; size_t messageDepth = 0; MutexIF* queueLock; bool defaultDestinationSet = false; - MessageQueueId_t defaultDestination = 0; - MessageQueueId_t lastPartner = 0; + MessageQueueId_t defaultDestination = MessageQueueIF::NO_QUEUE; + MessageQueueId_t lastPartner = MessageQueueIF::NO_QUEUE; }; #endif /* FRAMEWORK_OSAL_HOST_MESSAGEQUEUE_H_ */ From 9d0155d9ae58425bf982cd4712be3b7d83efc87b Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Tue, 11 May 2021 15:30:49 +0200 Subject: [PATCH 09/21] Added a returnvalue --- osal/host/MessageQueue.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osal/host/MessageQueue.cpp b/osal/host/MessageQueue.cpp index 4e2862716..a779bdcb8 100644 --- a/osal/host/MessageQueue.cpp +++ b/osal/host/MessageQueue.cpp @@ -128,8 +128,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, internalErrorReporter->queueMessageNotSent(); } } - // TODO: Better returnvalue - return HasReturnvaluesIF::RETURN_FAILED; + return MessageQueueIF::DESTINATION_INVALID; } if(targetQueue->messageQueue.size() < targetQueue->messageDepth) { MutexGuard mutexLock(targetQueue->queueLock, MutexIF::TimeoutType::WAITING, 20); From e1c91f82b763b0d57710a16ab40697df87e6ce74 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 12 May 2021 10:54:10 +0200 Subject: [PATCH 10/21] some fixes and tweaks --- events/EventManager.cpp | 48 +++++++++++++++++++---------- objectmanager/ObjectManagerIF.h | 2 +- serviceinterface/ServiceInterface.h | 4 +-- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/events/EventManager.cpp b/events/EventManager.cpp index 5b2b31b54..2d4b6a495 100644 --- a/events/EventManager.cpp +++ b/events/EventManager.cpp @@ -2,7 +2,7 @@ #include "EventMessage.h" #include -#include "../serviceinterface/ServiceInterfaceStream.h" +#include "../serviceinterface/ServiceInterface.h" #include "../ipc/QueueFactory.h" #include "../ipc/MutexFactory.h" @@ -120,23 +120,39 @@ ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener, void EventManager::printEvent(EventMessage* message) { const char *string = 0; switch (message->getSeverity()) { - case severity::INFO: -#if DEBUG_INFO_EVENT == 1 - string = translateObject(message->getReporter()); + case severity::INFO: { +#if FSFW_DEBUG_INFO == 1 + string = translateObject(message->getReporter()); #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "EVENT: "; - if (string != 0) { - sif::info << string; - } else { - sif::info << "0x" << std::hex << message->getReporter() << std::dec; - } - sif::info << " reported " << translateEvents(message->getEvent()) << " (" - << std::dec << message->getEventId() << std::hex << ") P1: 0x" - << message->getParameter1() << " P2: 0x" - << message->getParameter2() << std::dec << std::endl; -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + sif::info << "EVENT: "; + if (string != 0) { + sif::info << string; + } + else { + sif::info << "0x" << std::hex << std::setfill('0') << std::setw(8) << + message->getReporter() << std::setfill(' ') << std::dec; + } + sif::info << " reported " << translateEvents(message->getEvent()) << " (" + << std::dec << message->getEventId() << std::hex << ") P1: 0x" + << message->getParameter1() << " P2: 0x" + << message->getParameter2() << std::dec << std::endl; +#else + const char totalString[140] = {}; + if (string != 0) { + snprintf((char*) totalString, sizeof(totalString),"Event: %s", string); + } + else { + snprintf((char*) totalString, sizeof(totalString),"Event: 0x%08x", + message->getReporter()); + } + snprintf((char*) totalString, sizeof(totalString), + " reported %s | ID %d | P1: 0x%x | P2: 0x%x\n", translateEvents(message->getEvent()), + message->getEventId(), message->getParameter1(), message->getParameter2()); + sif::printInfo("%s", totalString); +#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */ #endif /* DEBUG_INFO_EVENT == 1 */ - break; + break; + } default: string = translateObject(message->getReporter()); #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/objectmanager/ObjectManagerIF.h b/objectmanager/ObjectManagerIF.h index 8bebb609e..61e6f4237 100644 --- a/objectmanager/ObjectManagerIF.h +++ b/objectmanager/ObjectManagerIF.h @@ -4,7 +4,7 @@ #include "frameworkObjects.h" #include "SystemObjectIF.h" #include "../returnvalues/HasReturnvaluesIF.h" -#include "../serviceinterface/ServiceInterfaceStream.h" +#include "../serviceinterface/ServiceInterface.h" /** * @brief This class provides an interface to the global object manager. diff --git a/serviceinterface/ServiceInterface.h b/serviceinterface/ServiceInterface.h index 1f7e5e84a..e95dd9a47 100644 --- a/serviceinterface/ServiceInterface.h +++ b/serviceinterface/ServiceInterface.h @@ -5,9 +5,9 @@ #include "serviceInterfaceDefintions.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 -#include +#include "ServiceInterfaceStream.h" #else -#include +#include "ServiceInterfacePrinter.h" #endif #endif /* FSFW_SERVICEINTERFACE_SERVICEINTERFACE_H_ */ From cd016c8281598140708952e44c7823f71e1e63cf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 12 May 2021 13:40:26 +0200 Subject: [PATCH 11/21] event manager printout refactoring --- events/EventManager.cpp | 150 +++++++++++++++++++++++----------------- events/EventManager.h | 2 + 2 files changed, 87 insertions(+), 65 deletions(-) diff --git a/events/EventManager.cpp b/events/EventManager.cpp index 2d4b6a495..8e8f797fb 100644 --- a/events/EventManager.cpp +++ b/events/EventManager.cpp @@ -1,8 +1,6 @@ #include "EventManager.h" #include "EventMessage.h" -#include -#include "../serviceinterface/ServiceInterface.h" #include "../ipc/QueueFactory.h" #include "../ipc/MutexFactory.h" @@ -115,69 +113,6 @@ ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener, return result; } -#if FSFW_OBJ_EVENT_TRANSLATION == 1 - -void EventManager::printEvent(EventMessage* message) { - const char *string = 0; - switch (message->getSeverity()) { - case severity::INFO: { -#if FSFW_DEBUG_INFO == 1 - string = translateObject(message->getReporter()); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "EVENT: "; - if (string != 0) { - sif::info << string; - } - else { - sif::info << "0x" << std::hex << std::setfill('0') << std::setw(8) << - message->getReporter() << std::setfill(' ') << std::dec; - } - sif::info << " reported " << translateEvents(message->getEvent()) << " (" - << std::dec << message->getEventId() << std::hex << ") P1: 0x" - << message->getParameter1() << " P2: 0x" - << message->getParameter2() << std::dec << std::endl; -#else - const char totalString[140] = {}; - if (string != 0) { - snprintf((char*) totalString, sizeof(totalString),"Event: %s", string); - } - else { - snprintf((char*) totalString, sizeof(totalString),"Event: 0x%08x", - message->getReporter()); - } - snprintf((char*) totalString, sizeof(totalString), - " reported %s | ID %d | P1: 0x%x | P2: 0x%x\n", translateEvents(message->getEvent()), - message->getEventId(), message->getParameter1(), message->getParameter2()); - sif::printInfo("%s", totalString); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */ -#endif /* DEBUG_INFO_EVENT == 1 */ - break; - } - default: - string = translateObject(message->getReporter()); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "EventManager: "; - if (string != 0) { - sif::debug << string; - } - else { - sif::debug << "0x" << std::hex << message->getReporter() << std::dec; - } - sif::debug << " reported " << translateEvents(message->getEvent()) - << " (" << std::dec << message->getEventId() << ") " - << std::endl; - sif::debug << std::hex << "P1 Hex: 0x" << message->getParameter1() - << ", P1 Dec: " << std::dec << message->getParameter1() - << std::endl; - sif::debug << std::hex << "P2 Hex: 0x" << message->getParameter2() - << ", P2 Dec: " << std::dec << message->getParameter2() - << std::endl; -#endif - break; - } -} -#endif - void EventManager::lockMutex() { mutex->lockMutex(timeoutType, timeoutMs); } @@ -191,3 +126,88 @@ void EventManager::setMutexTimeout(MutexIF::TimeoutType timeoutType, this->timeoutType = timeoutType; this->timeoutMs = timeoutMs; } + +#if FSFW_OBJ_EVENT_TRANSLATION == 1 + +void EventManager::printEvent(EventMessage* message) { + switch (message->getSeverity()) { + case severity::INFO: { +#if FSFW_DEBUG_INFO == 1 + printUtility(sif::OutputTypes::OUT_INFO, message); +#endif /* DEBUG_INFO_EVENT == 1 */ + break; + } + default: + printUtility(sif::OutputTypes::OUT_DEBUG, message); + break; + } +} + +void EventManager::printUtility(sif::OutputTypes printType, EventMessage *message) { + const char *string = 0; + if(printType == sif::OutputTypes::OUT_INFO) { + string = translateObject(message->getReporter()); +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::info << "EventManager: "; + if (string != 0) { + sif::info << string; + } + else { + sif::info << "0x" << std::hex << std::setw(8) << std::setfill('0') << + message->getReporter() << std::setfill(' ') << std::dec; + } + sif::info << " reported " << translateEvents(message->getEvent()) + << " with event ID " << std::dec << message->getEventId() << std::endl; + sif::info << std::hex << "P1 Hex: 0x" << message->getParameter1() << + " | P1 Dec: " << std::dec << message->getParameter1() << std::hex << + " | P2 Hex: 0x" << message->getParameter2() << " | P2 Dec: " << std::dec << + message->getParameter2() << std::endl; +#else + if (string != 0) { + sif::printInfo("Event Manager: %s reported %s with event ID %d\n", + message->getReporter(), translateEvents(message->getEvent()), + message->getEventId()); + } + else { + sif::printInfo("Event Manager: Reporter ID 0x%08x reported %s with event ID %d\n", + string, translateEvents(message->getEvent()), message->getEventId()); + } + sif::printInfo("P1 Hex: 0x%x | P1 Dec: %d | P2 Hex: 0x%x | P2 Dec: %d\n", + message->getParameter1(), message->getParameter1(), + message->getParameter2(), message->getParameter2()); +#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */ + } + else { + string = translateObject(message->getReporter()); +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::debug << "EventManager: "; + if (string != 0) { + sif::debug << string; + } + else { + sif::debug << "0x" << std::hex << message->getReporter() << std::dec; + } + sif::debug << " reported " << translateEvents(message->getEvent()) + << " with event ID " << std::dec << message->getEventId() << std::endl; + sif::debug << std::hex << "P1 Hex: 0x" << message->getParameter1() << + " | P1 Dec: " << std::dec << message->getParameter1() << std::hex << + " | P2 Hex: 0x" << message->getParameter2() << " | P2 Dec: " << std::dec << + message->getParameter2() << std::endl; +#else + if (string != 0) { + sif::printDebug("Event Manager: %s reported %s with event ID %d\n", + message->getReporter(), translateEvents(message->getEvent()), + message->getEventId()); + } + else { + sif::printDebug("Event Manager: Reporter ID 0x%08x reported %s with event ID %d\n", + string, translateEvents(message->getEvent()), message->getEventId()); + } + sif::printDebug("P1 Hex: 0x%x | P1 Dec: %d | P2 Hex: 0x%x | P2 Dec: %d\n", + message->getParameter1(), message->getParameter1(), + message->getParameter2(), message->getParameter2()); +#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */ + } +} + +#endif /* FSFW_OBJ_EVENT_TRANSLATION == 1 */ diff --git a/events/EventManager.h b/events/EventManager.h index abce9b8ba..9189d9e7d 100644 --- a/events/EventManager.h +++ b/events/EventManager.h @@ -6,6 +6,7 @@ #include +#include "../serviceinterface/ServiceInterface.h" #include "../objectmanager/SystemObject.h" #include "../storagemanager/LocalPool.h" #include "../tasks/ExecutableObjectIF.h" @@ -67,6 +68,7 @@ protected: #if FSFW_OBJ_EVENT_TRANSLATION == 1 void printEvent(EventMessage *message); + void printUtility(sif::OutputTypes printType, EventMessage* message); #endif void lockMutex(); From 5b23b928cf9b187eb19b18f366a9fecfaff21c31 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 12 May 2021 14:28:37 +0200 Subject: [PATCH 12/21] added missing include --- osal/host/MessageQueue.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osal/host/MessageQueue.cpp b/osal/host/MessageQueue.cpp index 41c55a3df..4e2862716 100644 --- a/osal/host/MessageQueue.cpp +++ b/osal/host/MessageQueue.cpp @@ -5,6 +5,8 @@ #include "../../ipc/MutexFactory.h" #include "../../ipc/MutexGuard.h" +#include + MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize): messageSize(maxMessageSize), messageDepth(messageDepth) { queueLock = MutexFactory::instance()->createMutex(); From d81c6f40fbc86ac9fd0123d08b5fdba09bad9d00 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 12 May 2021 14:43:08 +0200 Subject: [PATCH 13/21] define fixes --- osal/host/Clock.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osal/host/Clock.cpp b/osal/host/Clock.cpp index c097f6199..bcf486ecd 100644 --- a/osal/host/Clock.cpp +++ b/osal/host/Clock.cpp @@ -2,9 +2,9 @@ #include "../../timemanager/Clock.h" #include -#if defined(WIN32) +#if defined(_WIN32) #include -#elif defined(LINUX) +#elif defined(__unix__) #include #endif @@ -92,7 +92,7 @@ timeval Clock::getUptime() { auto fraction = uptime - secondsChrono; timeval.tv_usec = std::chrono::duration_cast( fraction).count(); -#elif defined(LINUX) +#elif defined(__unix__) double uptimeSeconds; if (std::ifstream("/proc/uptime", std::ios::in) >> uptimeSeconds) { @@ -120,7 +120,6 @@ ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { } -ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { /* Do some magic with chrono (C++20!) */ /* Right now, the library doesn't have the new features to get the required values yet. so we work around that for now. */ From 8293e6b0c742e18ddd78d4db05ac64fe58f09c60 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 12 May 2021 14:48:39 +0200 Subject: [PATCH 14/21] more include fixes --- osal/host/Clock.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osal/host/Clock.cpp b/osal/host/Clock.cpp index bcf486ecd..cf9349c12 100644 --- a/osal/host/Clock.cpp +++ b/osal/host/Clock.cpp @@ -46,7 +46,7 @@ ReturnValue_t Clock::setClock(const timeval* time) { } ReturnValue_t Clock::getClock_timeval(timeval* time) { -#if defined(WIN32) +#if defined(_WIN32) auto now = std::chrono::system_clock::now(); auto secondsChrono = std::chrono::time_point_cast(now); auto epoch = now.time_since_epoch(); @@ -54,7 +54,7 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) { auto fraction = now - secondsChrono; time->tv_usec = std::chrono::duration_cast(fraction).count(); return HasReturnvaluesIF::RETURN_OK; -#elif defined(LINUX) +#elif defined(__unix__) timespec timeUnix; int status = clock_gettime(CLOCK_REALTIME,&timeUnix); if(status!=0){ @@ -85,7 +85,7 @@ ReturnValue_t Clock::getClock_usecs(uint64_t* time) { timeval Clock::getUptime() { timeval timeval; -#if defined(WIN32) +#if defined(_WIN32) auto uptime = std::chrono::milliseconds(GetTickCount64()); auto secondsChrono = std::chrono::duration_cast(uptime); timeval.tv_sec = secondsChrono.count(); From a6dd2d5dcb21058c4c487ac1ef027ea6ece1b98f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 12 May 2021 16:37:12 +0200 Subject: [PATCH 15/21] event manager update --- events/EventManager.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/events/EventManager.cpp b/events/EventManager.cpp index 8e8f797fb..2337ba83f 100644 --- a/events/EventManager.cpp +++ b/events/EventManager.cpp @@ -156,21 +156,19 @@ void EventManager::printUtility(sif::OutputTypes printType, EventMessage *messag sif::info << "0x" << std::hex << std::setw(8) << std::setfill('0') << message->getReporter() << std::setfill(' ') << std::dec; } - sif::info << " reported " << translateEvents(message->getEvent()) - << " with event ID " << std::dec << message->getEventId() << std::endl; + sif::info << " report event with ID " << message->getEventId() << std::endl; sif::info << std::hex << "P1 Hex: 0x" << message->getParameter1() << " | P1 Dec: " << std::dec << message->getParameter1() << std::hex << " | P2 Hex: 0x" << message->getParameter2() << " | P2 Dec: " << std::dec << message->getParameter2() << std::endl; #else if (string != 0) { - sif::printInfo("Event Manager: %s reported %s with event ID %d\n", - message->getReporter(), translateEvents(message->getEvent()), + sif::printInfo("Event Manager: %s reported event with ID %d\n", string, message->getEventId()); } else { - sif::printInfo("Event Manager: Reporter ID 0x%08x reported %s with event ID %d\n", - string, translateEvents(message->getEvent()), message->getEventId()); + sif::printInfo("Event Manager: Reporter ID 0x%08x reported event with ID %d\n", + message->getReporter(), message->getEventId()); } sif::printInfo("P1 Hex: 0x%x | P1 Dec: %d | P2 Hex: 0x%x | P2 Dec: %d\n", message->getParameter1(), message->getParameter1(), @@ -185,23 +183,22 @@ void EventManager::printUtility(sif::OutputTypes printType, EventMessage *messag sif::debug << string; } else { - sif::debug << "0x" << std::hex << message->getReporter() << std::dec; + sif::debug << "0x" << std::hex << std::setw(8) << std::setfill('0') << + message->getReporter() << std::setfill(' ') << std::dec; } - sif::debug << " reported " << translateEvents(message->getEvent()) - << " with event ID " << std::dec << message->getEventId() << std::endl; + sif::debug << " report event with ID " << message->getEventId() << std::endl; sif::debug << std::hex << "P1 Hex: 0x" << message->getParameter1() << " | P1 Dec: " << std::dec << message->getParameter1() << std::hex << " | P2 Hex: 0x" << message->getParameter2() << " | P2 Dec: " << std::dec << message->getParameter2() << std::endl; #else if (string != 0) { - sif::printDebug("Event Manager: %s reported %s with event ID %d\n", - message->getReporter(), translateEvents(message->getEvent()), + sif::printDebug("Event Manager: %s reported event with ID %d\n", string, message->getEventId()); } else { - sif::printDebug("Event Manager: Reporter ID 0x%08x reported %s with event ID %d\n", - string, translateEvents(message->getEvent()), message->getEventId()); + sif::printDebug("Event Manager: Reporter ID 0x%08x reported event with ID %d\n", + message->getReporter(), message->getEventId()); } sif::printDebug("P1 Hex: 0x%x | P1 Dec: %d | P2 Hex: 0x%x | P2 Dec: %d\n", message->getParameter1(), message->getParameter1(), From d27f49c9680190169e004dead07ae0ebe0cc4fc4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 12 May 2021 16:38:02 +0200 Subject: [PATCH 16/21] added platform header file --- platform.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 platform.h diff --git a/platform.h b/platform.h new file mode 100644 index 000000000..08260094d --- /dev/null +++ b/platform.h @@ -0,0 +1,15 @@ +#ifndef FSFW_PLATFORM_H_ +#define FSFW_PLATFORM_H_ + +#if defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)) + +#define PLATFORM_UNIX + +#elif defined(_WIN32) + +#define PLATFORM_WIN + +#endif + + +#endif /* FSFW_PLATFORM_H_ */ From 1626b266d703f10444b6ea3f9fb1c1be228ec400 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 12 May 2021 16:47:53 +0200 Subject: [PATCH 17/21] platform header file --- osal/common/TcpIpBase.cpp | 13 ++++++------- osal/common/TcpIpBase.h | 9 +++++---- osal/common/TcpTmTcServer.cpp | 8 +++----- osal/common/TcpTmTcServer.h | 3 ++- osal/common/UdpTcPollingTask.cpp | 13 +++++-------- osal/common/UdpTmTcBridge.cpp | 15 ++++++--------- osal/common/UdpTmTcBridge.h | 9 +++------ osal/host/Clock.cpp | 6 ++++-- osal/host/FixedTimeslotTask.cpp | 5 +++-- osal/host/PeriodicTask.cpp | 9 +++++---- 10 files changed, 42 insertions(+), 48 deletions(-) diff --git a/osal/common/TcpIpBase.cpp b/osal/common/TcpIpBase.cpp index 27384ecc7..0b37e38ca 100644 --- a/osal/common/TcpIpBase.cpp +++ b/osal/common/TcpIpBase.cpp @@ -1,10 +1,9 @@ #include "TcpIpBase.h" +#include "../../platform.h" -#ifdef __unix__ - +#ifdef PLATFORM_UNIX #include #include - #endif TcpIpBase::TcpIpBase() { @@ -37,17 +36,17 @@ TcpIpBase::~TcpIpBase() { } int TcpIpBase::closeSocket(socket_t socket) { -#ifdef _WIN32 +#ifdef PLATFORM_WIN return closesocket(socket); -#elif defined(__unix__) +#elif defined(PLATFORM_UNIX) return close(socket); #endif } int TcpIpBase::getLastSocketError() { -#ifdef _WIN32 +#ifdef PLATFORM_WIN return WSAGetLastError(); -#elif defined(__unix__) +#elif defined(PLATFORM_UNIX) return errno; #endif } diff --git a/osal/common/TcpIpBase.h b/osal/common/TcpIpBase.h index 652d791a1..79eefad2b 100644 --- a/osal/common/TcpIpBase.h +++ b/osal/common/TcpIpBase.h @@ -1,13 +1,14 @@ #ifndef FSFW_OSAL_COMMON_TCPIPIF_H_ #define FSFW_OSAL_COMMON_TCPIPIF_H_ -#include +#include "../../returnvalues/HasReturnvaluesIF.h" +#include "../../platform.h" -#ifdef _WIN32 +#ifdef PLATFORM_WIN #include -#elif defined(__unix__) +#elif defined(PLATFORM_UNIX) #include @@ -16,7 +17,7 @@ class TcpIpBase { protected: -#ifdef _WIN32 +#ifdef PLATFORM_WIN static constexpr int SHUT_RECV = SD_RECEIVE; static constexpr int SHUT_SEND = SD_SEND; static constexpr int SHUT_BOTH = SD_BOTH; diff --git a/osal/common/TcpTmTcServer.cpp b/osal/common/TcpTmTcServer.cpp index 08a62ffb9..e1a26fe7f 100644 --- a/osal/common/TcpTmTcServer.cpp +++ b/osal/common/TcpTmTcServer.cpp @@ -1,15 +1,13 @@ #include "TcpTmTcServer.h" #include "tcpipHelpers.h" +#include "../../platform.h" #include "../../serviceinterface/ServiceInterface.h" -#ifdef _WIN32 +#ifdef PLATFORM_WIN #include #include - -#elif defined(__unix__) - +#elif defined(PLATFORM_UNIX) #include - #endif const std::string TcpTmTcServer::DEFAULT_TCP_SERVER_PORT = "7301"; diff --git a/osal/common/TcpTmTcServer.h b/osal/common/TcpTmTcServer.h index 4dcc77a2d..91c579e5c 100644 --- a/osal/common/TcpTmTcServer.h +++ b/osal/common/TcpTmTcServer.h @@ -2,10 +2,11 @@ #define FSFW_OSAL_WINDOWS_TCWINTCPSERVER_H_ #include "TcpIpBase.h" +#include "../../platform.h" #include "../../objectmanager/SystemObject.h" #include "../../tasks/ExecutableObjectIF.h" -#ifdef __unix__ +#ifdef PLATFORM_UNIX #include #endif diff --git a/osal/common/UdpTcPollingTask.cpp b/osal/common/UdpTcPollingTask.cpp index 47f67b295..68108323a 100644 --- a/osal/common/UdpTcPollingTask.cpp +++ b/osal/common/UdpTcPollingTask.cpp @@ -1,17 +1,14 @@ #include "UdpTcPollingTask.h" #include "tcpipHelpers.h" +#include "../../platform.h" #include "../../globalfunctions/arrayprinter.h" #include "../../serviceinterface/ServiceInterfaceStream.h" -#ifdef _WIN32 - +#ifdef PLATFORM_WIN #include - -#else - +#elif defined(PLATFORM_UNIX) #include #include - #endif //! Debugging preprocessor define. @@ -155,7 +152,7 @@ ReturnValue_t UdpTcPollingTask::initializeAfterTaskCreation() { } void UdpTcPollingTask::setTimeout(double timeoutSeconds) { -#ifdef _WIN32 +#ifdef PLATFORM_WIN DWORD timeoutMs = timeoutSeconds * 1000.0; int result = setsockopt(serverSocket, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast(&timeoutMs), sizeof(DWORD)); @@ -165,7 +162,7 @@ void UdpTcPollingTask::setTimeout(double timeoutSeconds) { "receive timeout failed with " << strerror(errno) << std::endl; #endif } -#elif defined(__unix__) +#elif defined(PLATFORM_UNIX) timeval tval; tval = timevalOperations::toTimeval(timeoutSeconds); int result = setsockopt(serverSocket, SOL_SOCKET, SO_RCVTIMEO, diff --git a/osal/common/UdpTmTcBridge.cpp b/osal/common/UdpTmTcBridge.cpp index ba23f521b..2ecc7b7ca 100644 --- a/osal/common/UdpTmTcBridge.cpp +++ b/osal/common/UdpTmTcBridge.cpp @@ -1,18 +1,15 @@ +#include "UdpTmTcBridge.h" #include "tcpipHelpers.h" -#include -#include -#include - -#ifdef _WIN32 +#include "../../platform.h" +#include "../../serviceinterface/ServiceInterface.h" +#include "../../ipc/MutexGuard.h" +#ifdef PLATFORM_WIN #include - -#elif defined(__unix__) - +#elif defined(PLATFORM_UNIX) #include #include - #endif //! Debugging preprocessor define. diff --git a/osal/common/UdpTmTcBridge.h b/osal/common/UdpTmTcBridge.h index 8b8d19491..360643bbf 100644 --- a/osal/common/UdpTmTcBridge.h +++ b/osal/common/UdpTmTcBridge.h @@ -2,16 +2,13 @@ #define FSFW_OSAL_WINDOWS_TMTCWINUDPBRIDGE_H_ #include "TcpIpBase.h" +#include "../../platform.h" #include "../../tmtcservices/TmTcBridge.h" -#ifdef _WIN32 - +#ifdef PLATFORM_WIN #include - -#elif defined(__unix__) - +#elif defined(PLATFORM_UNIX) #include - #endif #include diff --git a/osal/host/Clock.cpp b/osal/host/Clock.cpp index cf9349c12..b2e4c171b 100644 --- a/osal/host/Clock.cpp +++ b/osal/host/Clock.cpp @@ -1,10 +1,12 @@ #include "../../serviceinterface/ServiceInterface.h" #include "../../timemanager/Clock.h" +#include "../../platform.h" #include -#if defined(_WIN32) + +#if defined(PLATFORM_WIN) #include -#elif defined(__unix__) +#elif defined(PLATFORM_UNIX) #include #endif diff --git a/osal/host/FixedTimeslotTask.cpp b/osal/host/FixedTimeslotTask.cpp index 89daa2786..55f374995 100644 --- a/osal/host/FixedTimeslotTask.cpp +++ b/osal/host/FixedTimeslotTask.cpp @@ -1,4 +1,5 @@ #include "taskHelpers.h" +#include "../../platform.h" #include "../../osal/host/FixedTimeslotTask.h" #include "../../ipc/MutexFactory.h" #include "../../osal/host/Mutex.h" @@ -9,10 +10,10 @@ #include #include -#if defined(WIN32) +#if defined(PLATFORM_WIN) #include #include "../windows/winTaskHelpers.h" -#elif defined(LINUX) +#elif defined(PLATFORM_UNIX) #include #endif diff --git a/osal/host/PeriodicTask.cpp b/osal/host/PeriodicTask.cpp index 09df410fe..4b3fa626e 100644 --- a/osal/host/PeriodicTask.cpp +++ b/osal/host/PeriodicTask.cpp @@ -2,6 +2,7 @@ #include "PeriodicTask.h" #include "taskHelpers.h" +#include "../../platform.h" #include "../../ipc/MutexFactory.h" #include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../tasks/ExecutableObjectIF.h" @@ -9,10 +10,10 @@ #include #include -#if defined(WIN32) +#if defined(PLATFORM_WIN) #include #include -#elif defined(__unix__) +#elif defined(PLATFORM_UNIX) #include #endif @@ -24,9 +25,9 @@ PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority, // It is probably possible to set task priorities by using the native // task handles for Windows / Linux mainThread = std::thread(&PeriodicTask::taskEntryPoint, this, this); -#if defined(_WIN32) +#if defined(PLATFORM_WIN) tasks::setTaskPriority(reinterpret_cast(mainThread.native_handle()), setPriority); -#elif defined(__unix__) +#elif defined(PLATFORM_UNIX) // TODO: We could reuse existing code here. #endif tasks::insertTaskName(mainThread.get_id(), taskName); From 4095be449ae4b6ebaf89fdcbfc5bc31b854594d5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 12 May 2021 17:32:40 +0200 Subject: [PATCH 18/21] some more preprocessor replacements --- osal/common/TcpIpBase.h | 6 +----- osal/host/Clock.cpp | 10 +++++----- platform.h | 5 ----- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/osal/common/TcpIpBase.h b/osal/common/TcpIpBase.h index 79eefad2b..fe6a763c2 100644 --- a/osal/common/TcpIpBase.h +++ b/osal/common/TcpIpBase.h @@ -5,13 +5,9 @@ #include "../../platform.h" #ifdef PLATFORM_WIN - #include - #elif defined(PLATFORM_UNIX) - #include - #endif class TcpIpBase { @@ -23,7 +19,7 @@ protected: static constexpr int SHUT_BOTH = SD_BOTH; using socket_t = SOCKET; -#elif defined(__unix__) +#elif defined(PLATFORM_UNIX) using socket_t = int; static constexpr int INVALID_SOCKET = -1; diff --git a/osal/host/Clock.cpp b/osal/host/Clock.cpp index b2e4c171b..ed5aab628 100644 --- a/osal/host/Clock.cpp +++ b/osal/host/Clock.cpp @@ -48,7 +48,7 @@ ReturnValue_t Clock::setClock(const timeval* time) { } ReturnValue_t Clock::getClock_timeval(timeval* time) { -#if defined(_WIN32) +#if defined(PLATFORM_WIN) auto now = std::chrono::system_clock::now(); auto secondsChrono = std::chrono::time_point_cast(now); auto epoch = now.time_since_epoch(); @@ -56,7 +56,7 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) { auto fraction = now - secondsChrono; time->tv_usec = std::chrono::duration_cast(fraction).count(); return HasReturnvaluesIF::RETURN_OK; -#elif defined(__unix__) +#elif defined(PLATFORM_UNIX) timespec timeUnix; int status = clock_gettime(CLOCK_REALTIME,&timeUnix); if(status!=0){ @@ -87,14 +87,14 @@ ReturnValue_t Clock::getClock_usecs(uint64_t* time) { timeval Clock::getUptime() { timeval timeval; -#if defined(_WIN32) +#if defined(PLATFORM_WIN) auto uptime = std::chrono::milliseconds(GetTickCount64()); auto secondsChrono = std::chrono::duration_cast(uptime); timeval.tv_sec = secondsChrono.count(); auto fraction = uptime - secondsChrono; timeval.tv_usec = std::chrono::duration_cast( fraction).count(); -#elif defined(__unix__) +#elif defined(PLATFORM_UNIX) double uptimeSeconds; if (std::ifstream("/proc/uptime", std::ios::in) >> uptimeSeconds) { @@ -121,7 +121,7 @@ ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { return HasReturnvaluesIF::RETURN_OK; } - +ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { /* Do some magic with chrono (C++20!) */ /* Right now, the library doesn't have the new features to get the required values yet. so we work around that for now. */ diff --git a/platform.h b/platform.h index 08260094d..4bca33984 100644 --- a/platform.h +++ b/platform.h @@ -2,14 +2,9 @@ #define FSFW_PLATFORM_H_ #if defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)) - #define PLATFORM_UNIX - #elif defined(_WIN32) - #define PLATFORM_WIN - #endif - #endif /* FSFW_PLATFORM_H_ */ From 4fa56a2f1d3424c2afa30d34013ce2e11533ae84 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 12 May 2021 18:37:52 +0200 Subject: [PATCH 19/21] moved string port argument --- osal/common/UdpTmTcBridge.cpp | 2 +- osal/common/UdpTmTcBridge.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osal/common/UdpTmTcBridge.cpp b/osal/common/UdpTmTcBridge.cpp index ba23f521b..a3b4efa7e 100644 --- a/osal/common/UdpTmTcBridge.cpp +++ b/osal/common/UdpTmTcBridge.cpp @@ -21,7 +21,7 @@ const std::string UdpTmTcBridge::DEFAULT_UDP_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT; UdpTmTcBridge::UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, - object_id_t tmStoreId, object_id_t tcStoreId, std::string udpServerPort): + std::string udpServerPort, object_id_t tmStoreId, object_id_t tcStoreId): TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { if(udpServerPort == "") { this->udpServerPort = DEFAULT_UDP_SERVER_PORT; diff --git a/osal/common/UdpTmTcBridge.h b/osal/common/UdpTmTcBridge.h index 8b8d19491..49d846a13 100644 --- a/osal/common/UdpTmTcBridge.h +++ b/osal/common/UdpTmTcBridge.h @@ -28,8 +28,8 @@ public: /* The ports chosen here should not be used by any other process. */ static const std::string DEFAULT_UDP_SERVER_PORT; - UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, - object_id_t tmStoreId, object_id_t tcStoreId, std::string udpServerPort = ""); + UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, std::string udpServerPort = "", + object_id_t tmStoreId = objects::TM_STORE, object_id_t tcStoreId = objects::TC_STORE); virtual~ UdpTmTcBridge(); /** From 0bc124fd2187bfad49589562bba812ac79a1d387 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 13 May 2021 21:46:46 +0200 Subject: [PATCH 20/21] renamed tcpip tasks --- unittest/user/testcfg/objects/systemObjectList.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unittest/user/testcfg/objects/systemObjectList.h b/unittest/user/testcfg/objects/systemObjectList.h index 88b92131c..76f1ff90c 100644 --- a/unittest/user/testcfg/objects/systemObjectList.h +++ b/unittest/user/testcfg/objects/systemObjectList.h @@ -15,8 +15,8 @@ namespace objects { PUS_DISTRIBUTOR = 11, TM_FUNNEL = 12, - UDP_BRIDGE = 15, - UDP_POLLING_TASK = 16, + TCPIP_BRIDGE = 15, + TCPIP_HELPER = 16, TEST_ECHO_COM_IF = 20, TEST_DEVICE = 21, From 5847081a246aea8d56b184e122052bd792b02661 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 13 May 2021 22:17:21 +0200 Subject: [PATCH 21/21] tweaks and fixes for TCP --- osal/common/TcpTmTcServer.cpp | 7 ++++--- osal/common/TcpTmTcServer.h | 2 +- osal/windows/tcpipHelpers.cpp | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/osal/common/TcpTmTcServer.cpp b/osal/common/TcpTmTcServer.cpp index 0663fed13..28fab4224 100644 --- a/osal/common/TcpTmTcServer.cpp +++ b/osal/common/TcpTmTcServer.cpp @@ -99,8 +99,8 @@ ReturnValue_t TcpTmTcServer::performOperation(uint8_t opCode) { using namespace tcpip; // If a connection is accepted, the corresponding socket will be assigned to the new socket socket_t connSocket = 0; - sockaddr clientSockAddr = {}; - socklen_t connectorSockAddrLen = 0; + // sockaddr clientSockAddr = {}; + // socklen_t connectorSockAddrLen = 0; int retval = 0; // Listen for connection requests permanently for lifetime of program @@ -111,7 +111,8 @@ ReturnValue_t TcpTmTcServer::performOperation(uint8_t opCode) { continue; } - connSocket = accept(listenerTcpSocket, &clientSockAddr, &connectorSockAddrLen); + //connSocket = accept(listenerTcpSocket, &clientSockAddr, &connectorSockAddrLen); + connSocket = accept(listenerTcpSocket, nullptr, nullptr); if(connSocket == INVALID_SOCKET) { handleError(Protocol::TCP, ErrorSources::ACCEPT_CALL, 500); diff --git a/osal/common/TcpTmTcServer.h b/osal/common/TcpTmTcServer.h index 191fff7b9..f7c36d69c 100644 --- a/osal/common/TcpTmTcServer.h +++ b/osal/common/TcpTmTcServer.h @@ -43,7 +43,7 @@ class TcpTmTcServer: public: /* The ports chosen here should not be used by any other process. */ static const std::string DEFAULT_TCP_SERVER_PORT; - static const std::string DEFAULT_TCP_CLIENT_PORT; + static constexpr size_t ETHERNET_MTU_SIZE = 1500; /** diff --git a/osal/windows/tcpipHelpers.cpp b/osal/windows/tcpipHelpers.cpp index 03278a92e..3dab9406c 100644 --- a/osal/windows/tcpipHelpers.cpp +++ b/osal/windows/tcpipHelpers.cpp @@ -50,8 +50,8 @@ void tcpip::handleError(Protocol protocol, ErrorSources errorSrc, dur_millis_t s sif::warning << "tcpip::handleError: " << protocolString << " | " << errorSrcString << " | " << infoString << std::endl; #else - sif::printWarning("tcpip::handleError: %s | %s | %s\n", protocolString, - errorSrcString, infoString); + sif::printWarning("tcpip::handleError: %s | %s | %s\n", protocolString.c_str(), + errorSrcString.c_str(), infoString.c_str()); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */