Merge branch 'development' into mueller/dle-improvements

This commit is contained in:
Robin Müller 2021-09-13 15:18:22 +02:00
commit 646b1139a6
12 changed files with 70 additions and 63 deletions

View File

@ -39,7 +39,7 @@ elseif(${CMAKE_CXX_STANDARD} LESS 11)
endif() endif()
# Backwards comptability # Backwards comptability
if(OS_FSFW) if(OS_FSFW AND NOT FSFW_OSAL)
message(WARNING "Please pass the FSFW OSAL as FSFW_OSAL instead of OS_FSFW") message(WARNING "Please pass the FSFW OSAL as FSFW_OSAL instead of OS_FSFW")
set(FSFW_OSAL OS_FSFW) set(FSFW_OSAL OS_FSFW)
endif() endif()
@ -64,18 +64,19 @@ set(FSFW_OSAL_DEFINITION FSFW_OSAL_HOST)
if(FSFW_OSAL MATCHES host) if(FSFW_OSAL MATCHES host)
set(OS_FSFW_NAME "Host") set(OS_FSFW_NAME "Host")
set(FSFW_OSAL_HOST ON)
elseif(FSFW_OSAL MATCHES linux) elseif(FSFW_OSAL MATCHES linux)
set(OS_FSFW_NAME "Linux") set(OS_FSFW_NAME "Linux")
set(FSFW_OSAL_DEFINITION FSFW_OSAL_LINUX) set(FSFW_OSAL_LINUX ON)
elseif(FSFW_OSAL MATCHES freertos) elseif(FSFW_OSAL MATCHES freertos)
set(OS_FSFW_NAME "FreeRTOS") set(OS_FSFW_NAME "FreeRTOS")
set(FSFW_OSAL_DEFINITION FSFW_OSAL_FREERTOS) set(FSFW_OSAL_FREERTOS ON)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE target_link_libraries(${LIB_FSFW_NAME} PRIVATE
${LIB_OS_NAME} ${LIB_OS_NAME}
) )
elseif(FSFW_OSAL STREQUAL rtems) elseif(FSFW_OSAL STREQUAL rtems)
set(OS_FSFW_NAME "RTEMS") set(OS_FSFW_NAME "RTEMS")
set(FSFW_OSAL_DEFINITION FSFW_OSAL_RTEMS) set(FSFW_OSAL_RTEMS ON)
else() else()
message(WARNING message(WARNING
"Invalid operating system for FSFW specified! Setting to host.." "Invalid operating system for FSFW specified! Setting to host.."
@ -84,14 +85,6 @@ else()
set(OS_FSFW "host") set(OS_FSFW "host")
endif() endif()
target_compile_definitions(${LIB_FSFW_NAME} PRIVATE
${FSFW_OSAL_DEFINITION}
)
target_compile_definitions(${LIB_FSFW_NAME} INTERFACE
${FSFW_OSAL_DEFINITION}
)
message(STATUS "Compiling FSFW for the ${OS_FSFW_NAME} operating system.") message(STATUS "Compiling FSFW for the ${OS_FSFW_NAME} operating system.")
add_subdirectory(src) add_subdirectory(src)

View File

@ -1,5 +1,10 @@
#include "fsfw/FSFW.h"
#include "fsfw/serviceinterface.h"
#include "fsfw_hal/linux/UnixFileGuard.h" #include "fsfw_hal/linux/UnixFileGuard.h"
#include <cerrno>
#include <cstring>
UnixFileGuard::UnixFileGuard(std::string device, int* fileDescriptor, int flags, UnixFileGuard::UnixFileGuard(std::string device, int* fileDescriptor, int flags,
std::string diagnosticPrefix): std::string diagnosticPrefix):
fileDescriptor(fileDescriptor) { fileDescriptor(fileDescriptor) {
@ -10,12 +15,11 @@ UnixFileGuard::UnixFileGuard(std::string device, int* fileDescriptor, int flags,
if (*fileDescriptor < 0) { if (*fileDescriptor < 0) {
#if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << diagnosticPrefix <<"Opening device failed with error code " << errno << sif::warning << diagnosticPrefix << ": Opening device failed with error code " <<
"." << std::endl; errno << ": " << strerror(errno) << std::endl;
sif::warning << "Error description: " << strerror(errno) << std::endl;
#else #else
sif::printError("%sOpening device failed with error code %d.\n", diagnosticPrefix); sif::printWarning("%s: Opening device failed with error code %d: %s\n",
sif::printWarning("Error description: %s\n", strerror(errno)); diagnosticPrefix, errno, strerror(errno));
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
#endif /* FSFW_VERBOSE_LEVEL >= 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */
openStatus = OPEN_FILE_FAILED; openStatus = OPEN_FILE_FAILED;

View File

@ -90,7 +90,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) {
int fileDescriptor = 0; int fileDescriptor = 0;
UnixFileGuard fileHelper(spiCookie->getSpiDevice(), &fileDescriptor, O_RDWR, UnixFileGuard fileHelper(spiCookie->getSpiDevice(), &fileDescriptor, O_RDWR,
"SpiComIF::initializeInterface: "); "SpiComIF::initializeInterface");
if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
return fileHelper.getOpenResult(); return fileHelper.getOpenResult();
} }
@ -184,7 +184,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie *spiCookie, const
/* Prepare transfer */ /* Prepare transfer */
int fileDescriptor = 0; int fileDescriptor = 0;
std::string device = spiCookie->getSpiDevice(); std::string device = spiCookie->getSpiDevice();
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage: "); UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage");
if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
return OPENING_FILE_FAILED; return OPENING_FILE_FAILED;
} }
@ -273,7 +273,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
std::string device = spiCookie->getSpiDevice(); std::string device = spiCookie->getSpiDevice();
int fileDescriptor = 0; int fileDescriptor = 0;
UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR,
"SpiComIF::requestReceiveMessage: "); "SpiComIF::requestReceiveMessage");
if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
return OPENING_FILE_FAILED; return OPENING_FILE_FAILED;
} }

View File

@ -3,6 +3,11 @@
#include "FSFWConfig.h" #include "FSFWConfig.h"
#cmakedefine FSFW_OSAL_RTEMS
#cmakedefine FSFW_OSAL_FREERTOS
#cmakedefine FSFW_OSAL_LINUX
#cmakedefine FSFW_OSAL_HOST
#cmakedefine FSFW_ADD_RMAP #cmakedefine FSFW_ADD_RMAP
#cmakedefine FSFW_ADD_DATALINKLAYER #cmakedefine FSFW_ADD_DATALINKLAYER
#cmakedefine FSFW_ADD_TMSTORAGE #cmakedefine FSFW_ADD_TMSTORAGE

View File

@ -1,12 +1,10 @@
#ifndef FSFW_DEFAULTCFG_VERSION_H_ #ifndef FSFW_VERSION_H_
#define FSFW_DEFAULTCFG_VERSION_H_ #define FSFW_VERSION_H_
const char* const FSFW_VERSION_NAME = "ASTP"; const char* const FSFW_VERSION_NAME = "ASTP";
#define FSFW_VERSION 1 #define FSFW_VERSION 1
#define FSFW_SUBVERSION 0 #define FSFW_SUBVERSION 2
#define FSFW_REVISION 0 #define FSFW_REVISION 0
#endif /* FSFW_VERSION_H_ */
#endif /* FSFW_DEFAULTCFG_VERSION_H_ */

View File

@ -1,6 +1,5 @@
#include "fsfw/platform.h" #include "fsfw/platform.h"
#include "fsfw/osal/common/TcpTmTcBridge.h" #include "fsfw/osal/common/TcpTmTcBridge.h"
#include "fsfw/osal/common/tcpipHelpers.h"
#include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/ipc/MutexGuard.h" #include "fsfw/ipc/MutexGuard.h"
@ -17,8 +16,6 @@
#endif #endif
const std::string TcpTmTcBridge::DEFAULT_UDP_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT;
TcpTmTcBridge::TcpTmTcBridge(object_id_t objectId, object_id_t tcDestination, TcpTmTcBridge::TcpTmTcBridge(object_id_t objectId, object_id_t tcDestination,
object_id_t tmStoreId, object_id_t tcStoreId): object_id_t tmStoreId, object_id_t tcStoreId):
TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) {

View File

@ -2,7 +2,7 @@
#define FSFW_OSAL_COMMON_TCPTMTCBRIDGE_H_ #define FSFW_OSAL_COMMON_TCPTMTCBRIDGE_H_
#include "TcpIpBase.h" #include "TcpIpBase.h"
#include "../../tmtcservices/TmTcBridge.h" #include "fsfw/tmtcservices/TmTcBridge.h"
#ifdef _WIN32 #ifdef _WIN32
@ -29,8 +29,6 @@ class TcpTmTcBridge:
public TmTcBridge { public TmTcBridge {
friend class TcpTmTcServer; friend class TcpTmTcServer;
public: public:
/* The ports chosen here should not be used by any other process. */
static const std::string DEFAULT_UDP_SERVER_PORT;
/** /**
* Constructor * Constructor

View File

@ -22,14 +22,14 @@
#define FSFW_TCP_RECV_WIRETAPPING_ENABLED 0 #define FSFW_TCP_RECV_WIRETAPPING_ENABLED 0
#endif #endif
const std::string TcpTmTcServer::DEFAULT_TCP_SERVER_PORT = "7303"; const std::string TcpTmTcServer::DEFAULT_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT;
TcpTmTcServer::TcpTmTcServer(object_id_t objectId, object_id_t tmtcTcpBridge, TcpTmTcServer::TcpTmTcServer(object_id_t objectId, object_id_t tmtcTcpBridge,
size_t receptionBufferSize, std::string customTcpServerPort): size_t receptionBufferSize, std::string customTcpServerPort):
SystemObject(objectId), tmtcBridgeId(tmtcTcpBridge), SystemObject(objectId), tmtcBridgeId(tmtcTcpBridge),
tcpPort(customTcpServerPort), receptionBuffer(receptionBufferSize) { tcpPort(customTcpServerPort), receptionBuffer(receptionBufferSize) {
if(tcpPort == "") { if(tcpPort == "") {
tcpPort = DEFAULT_TCP_SERVER_PORT; tcpPort = DEFAULT_SERVER_PORT;
} }
} }
@ -200,6 +200,10 @@ void TcpTmTcServer::setTcpBacklog(uint8_t tcpBacklog) {
this->tcpBacklog = tcpBacklog; this->tcpBacklog = tcpBacklog;
} }
std::string TcpTmTcServer::getTcpPort() const {
return tcpPort;
}
ReturnValue_t TcpTmTcServer::handleTmSending(socket_t connSocket) { ReturnValue_t TcpTmTcServer::handleTmSending(socket_t connSocket) {
// Access to the FIFO is mutex protected because it is filled by the bridge // Access to the FIFO is mutex protected because it is filled by the bridge
MutexGuard(tmtcBridge->mutex, tmtcBridge->timeoutType, tmtcBridge->mutexTimeoutMs); MutexGuard(tmtcBridge->mutex, tmtcBridge->timeoutType, tmtcBridge->mutexTimeoutMs);

View File

@ -3,13 +3,14 @@
#include "TcpIpBase.h" #include "TcpIpBase.h"
#include "../../platform.h" #include "fsfw/platform.h"
#include "../../ipc/messageQueueDefinitions.h" #include "fsfw/osal/common/tcpipHelpers.h"
#include "../../ipc/MessageQueueIF.h" #include "fsfw/ipc/messageQueueDefinitions.h"
#include "../../objectmanager/frameworkObjects.h" #include "fsfw/ipc/MessageQueueIF.h"
#include "../../objectmanager/SystemObject.h" #include "fsfw/objectmanager/frameworkObjects.h"
#include "../../storagemanager/StorageManagerIF.h" #include "fsfw/objectmanager/SystemObject.h"
#include "../../tasks/ExecutableObjectIF.h" #include "fsfw/storagemanager/StorageManagerIF.h"
#include "fsfw/tasks/ExecutableObjectIF.h"
#ifdef PLATFORM_UNIX #ifdef PLATFORM_UNIX
#include <sys/socket.h> #include <sys/socket.h>
@ -41,8 +42,7 @@ class TcpTmTcServer:
public TcpIpBase, public TcpIpBase,
public ExecutableObjectIF { public ExecutableObjectIF {
public: public:
/* The ports chosen here should not be used by any other process. */ static const std::string DEFAULT_SERVER_PORT;
static const std::string DEFAULT_TCP_SERVER_PORT;
static constexpr size_t ETHERNET_MTU_SIZE = 1500; static constexpr size_t ETHERNET_MTU_SIZE = 1500;
@ -65,6 +65,8 @@ public:
ReturnValue_t performOperation(uint8_t opCode) override; ReturnValue_t performOperation(uint8_t opCode) override;
ReturnValue_t initializeAfterTaskCreation() override; ReturnValue_t initializeAfterTaskCreation() override;
std::string getTcpPort() const;
protected: protected:
StorageManagerIF* tcStore = nullptr; StorageManagerIF* tcStore = nullptr;
StorageManagerIF* tmStore = nullptr; StorageManagerIF* tmStore = nullptr;

View File

@ -17,13 +17,13 @@
#define FSFW_UDP_SEND_WIRETAPPING_ENABLED 0 #define FSFW_UDP_SEND_WIRETAPPING_ENABLED 0
#endif #endif
const std::string UdpTmTcBridge::DEFAULT_UDP_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT; const std::string UdpTmTcBridge::DEFAULT_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT;
UdpTmTcBridge::UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, UdpTmTcBridge::UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination,
std::string udpServerPort, object_id_t tmStoreId, object_id_t tcStoreId): std::string udpServerPort, object_id_t tmStoreId, object_id_t tcStoreId):
TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) {
if(udpServerPort == "") { if(udpServerPort == "") {
this->udpServerPort = DEFAULT_UDP_SERVER_PORT; this->udpServerPort = DEFAULT_SERVER_PORT;
} }
else { else {
this->udpServerPort = udpServerPort; this->udpServerPort = udpServerPort;
@ -108,6 +108,10 @@ UdpTmTcBridge::~UdpTmTcBridge() {
} }
} }
std::string UdpTmTcBridge::getUdpPort() const {
return udpServerPort;
}
ReturnValue_t UdpTmTcBridge::sendTm(const uint8_t *data, size_t dataLen) { ReturnValue_t UdpTmTcBridge::sendTm(const uint8_t *data, size_t dataLen) {
int flags = 0; int flags = 0;

View File

@ -2,8 +2,8 @@
#define FSFW_OSAL_COMMON_TMTCUDPBRIDGE_H_ #define FSFW_OSAL_COMMON_TMTCUDPBRIDGE_H_
#include "TcpIpBase.h" #include "TcpIpBase.h"
#include "../../platform.h" #include "fsfw/platform.h"
#include "../../tmtcservices/TmTcBridge.h" #include "fsfw/tmtcservices/TmTcBridge.h"
#ifdef PLATFORM_WIN #ifdef PLATFORM_WIN
#include <ws2tcpip.h> #include <ws2tcpip.h>
@ -28,7 +28,7 @@ class UdpTmTcBridge:
friend class UdpTcPollingTask; friend class UdpTcPollingTask;
public: public:
/* The ports chosen here should not be used by any other process. */ /* The ports chosen here should not be used by any other process. */
static const std::string DEFAULT_UDP_SERVER_PORT; static const std::string DEFAULT_SERVER_PORT;
UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination,
std::string udpServerPort = "", object_id_t tmStoreId = objects::TM_STORE, std::string udpServerPort = "", object_id_t tmStoreId = objects::TM_STORE,
@ -44,6 +44,8 @@ public:
void checkAndSetClientAddress(sockaddr& clientAddress); void checkAndSetClientAddress(sockaddr& clientAddress);
std::string getUdpPort() const;
protected: protected:
virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) override; virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) override;

View File

@ -1,7 +1,7 @@
#ifndef FSFW_OSAL_COMMON_TCPIPCOMMON_H_ #ifndef FSFW_OSAL_COMMON_TCPIPCOMMON_H_
#define FSFW_OSAL_COMMON_TCPIPCOMMON_H_ #define FSFW_OSAL_COMMON_TCPIPCOMMON_H_
#include "../../timemanager/clockDefinitions.h" #include "fsfw/timemanager/clockDefinitions.h"
#include <string> #include <string>
#ifdef _WIN32 #ifdef _WIN32
@ -13,7 +13,7 @@
namespace tcpip { namespace tcpip {
const char* const DEFAULT_SERVER_PORT = "7301"; static constexpr char DEFAULT_SERVER_PORT[] = "7301";
enum class Protocol { enum class Protocol {
UDP, UDP,