Merge pull request 'Update Package' (#420) from KSat/fsfw:mueller/update-package into development
Reviewed-on: fsfw/fsfw#420
This commit is contained in:
commit
2737bc390c
@ -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
|
target_include_directories(${TARGET_NAME} PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT FSFW_CONFIG_PATH)
|
target_sources(${TARGET_NAME} PRIVATE
|
||||||
set(FSFW_CONFIG_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
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()
|
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()
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#include "EventManager.h"
|
#include "EventManager.h"
|
||||||
#include "EventMessage.h"
|
#include "EventMessage.h"
|
||||||
|
|
||||||
#include <FSFWConfig.h>
|
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
|
||||||
#include "../ipc/QueueFactory.h"
|
#include "../ipc/QueueFactory.h"
|
||||||
#include "../ipc/MutexFactory.h"
|
#include "../ipc/MutexFactory.h"
|
||||||
|
|
||||||
@ -115,53 +113,6 @@ ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
|
||||||
|
|
||||||
void EventManager::printEvent(EventMessage* message) {
|
|
||||||
const char *string = 0;
|
|
||||||
switch (message->getSeverity()) {
|
|
||||||
case severity::INFO:
|
|
||||||
#if DEBUG_INFO_EVENT == 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 */
|
|
||||||
#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() {
|
void EventManager::lockMutex() {
|
||||||
mutex->lockMutex(timeoutType, timeoutMs);
|
mutex->lockMutex(timeoutType, timeoutMs);
|
||||||
}
|
}
|
||||||
@ -175,3 +126,85 @@ void EventManager::setMutexTimeout(MutexIF::TimeoutType timeoutType,
|
|||||||
this->timeoutType = timeoutType;
|
this->timeoutType = timeoutType;
|
||||||
this->timeoutMs = timeoutMs;
|
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 << " 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 event with ID %d\n", string,
|
||||||
|
message->getEventId());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
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(),
|
||||||
|
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 << std::setw(8) << std::setfill('0') <<
|
||||||
|
message->getReporter() << std::setfill(' ') << std::dec;
|
||||||
|
}
|
||||||
|
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 event with ID %d\n", string,
|
||||||
|
message->getEventId());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
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(),
|
||||||
|
message->getParameter2(), message->getParameter2());
|
||||||
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FSFW_OBJ_EVENT_TRANSLATION == 1 */
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <FSFWConfig.h>
|
#include <FSFWConfig.h>
|
||||||
|
|
||||||
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
#include "../objectmanager/SystemObject.h"
|
#include "../objectmanager/SystemObject.h"
|
||||||
#include "../storagemanager/LocalPool.h"
|
#include "../storagemanager/LocalPool.h"
|
||||||
#include "../tasks/ExecutableObjectIF.h"
|
#include "../tasks/ExecutableObjectIF.h"
|
||||||
@ -67,6 +68,7 @@ protected:
|
|||||||
|
|
||||||
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
||||||
void printEvent(EventMessage *message);
|
void printEvent(EventMessage *message);
|
||||||
|
void printUtility(sif::OutputTypes printType, EventMessage* message);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void lockMutex();
|
void lockMutex();
|
||||||
|
@ -22,11 +22,11 @@ public:
|
|||||||
static const uint8_t INTERFACE_ID = CLASS_ID::MESSAGE_QUEUE_IF;
|
static const uint8_t INTERFACE_ID = CLASS_ID::MESSAGE_QUEUE_IF;
|
||||||
//! No new messages on the queue
|
//! No new messages on the queue
|
||||||
static const ReturnValue_t EMPTY = MAKE_RETURN_CODE(1);
|
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);
|
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);
|
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);
|
static constexpr ReturnValue_t DESTINATION_INVALID = MAKE_RETURN_CODE(4);
|
||||||
|
|
||||||
virtual ~MessageQueueIF() {}
|
virtual ~MessageQueueIF() {}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "frameworkObjects.h"
|
#include "frameworkObjects.h"
|
||||||
#include "SystemObjectIF.h"
|
#include "SystemObjectIF.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class provides an interface to the global object manager.
|
* @brief This class provides an interface to the global object manager.
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#include "TcpIpBase.h"
|
#include "TcpIpBase.h"
|
||||||
|
#include "../../platform.h"
|
||||||
|
|
||||||
#ifdef __unix__
|
#ifdef PLATFORM_UNIX
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TcpIpBase::TcpIpBase() {
|
TcpIpBase::TcpIpBase() {
|
||||||
@ -37,17 +36,17 @@ TcpIpBase::~TcpIpBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int TcpIpBase::closeSocket(socket_t socket) {
|
int TcpIpBase::closeSocket(socket_t socket) {
|
||||||
#ifdef _WIN32
|
#ifdef PLATFORM_WIN
|
||||||
return closesocket(socket);
|
return closesocket(socket);
|
||||||
#elif defined(__unix__)
|
#elif defined(PLATFORM_UNIX)
|
||||||
return close(socket);
|
return close(socket);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int TcpIpBase::getLastSocketError() {
|
int TcpIpBase::getLastSocketError() {
|
||||||
#ifdef _WIN32
|
#ifdef PLATFORM_WIN
|
||||||
return WSAGetLastError();
|
return WSAGetLastError();
|
||||||
#elif defined(__unix__)
|
#elif defined(PLATFORM_UNIX)
|
||||||
return errno;
|
return errno;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,25 @@
|
|||||||
#ifndef FSFW_OSAL_COMMON_TCPIPIF_H_
|
#ifndef FSFW_OSAL_COMMON_TCPIPIF_H_
|
||||||
#define FSFW_OSAL_COMMON_TCPIPIF_H_
|
#define FSFW_OSAL_COMMON_TCPIPIF_H_
|
||||||
|
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include "../../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
#include "../../platform.h"
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
|
#ifdef PLATFORM_WIN
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
#elif defined(PLATFORM_UNIX)
|
||||||
#elif defined(__unix__)
|
|
||||||
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class TcpIpBase {
|
class TcpIpBase {
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef PLATFORM_WIN
|
||||||
static constexpr int SHUT_RECV = SD_RECEIVE;
|
static constexpr int SHUT_RECV = SD_RECEIVE;
|
||||||
static constexpr int SHUT_SEND = SD_SEND;
|
static constexpr int SHUT_SEND = SD_SEND;
|
||||||
static constexpr int SHUT_BOTH = SD_BOTH;
|
static constexpr int SHUT_BOTH = SD_BOTH;
|
||||||
|
|
||||||
using socket_t = SOCKET;
|
using socket_t = SOCKET;
|
||||||
#elif defined(__unix__)
|
#elif defined(PLATFORM_UNIX)
|
||||||
using socket_t = int;
|
using socket_t = int;
|
||||||
|
|
||||||
static constexpr int INVALID_SOCKET = -1;
|
static constexpr int INVALID_SOCKET = -1;
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
#include "TcpTmTcServer.h"
|
#include "TcpTmTcServer.h"
|
||||||
#include "tcpipHelpers.h"
|
#include "tcpipHelpers.h"
|
||||||
|
#include "../../platform.h"
|
||||||
#include "../../serviceinterface/ServiceInterface.h"
|
#include "../../serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef PLATFORM_WIN
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
#elif defined(PLATFORM_UNIX)
|
||||||
#elif defined(__unix__)
|
|
||||||
|
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const std::string TcpTmTcServer::DEFAULT_TCP_SERVER_PORT = "7301";
|
const std::string TcpTmTcServer::DEFAULT_TCP_SERVER_PORT = "7301";
|
||||||
|
@ -2,10 +2,11 @@
|
|||||||
#define FSFW_OSAL_WINDOWS_TCWINTCPSERVER_H_
|
#define FSFW_OSAL_WINDOWS_TCWINTCPSERVER_H_
|
||||||
|
|
||||||
#include "TcpIpBase.h"
|
#include "TcpIpBase.h"
|
||||||
|
#include "../../platform.h"
|
||||||
#include "../../objectmanager/SystemObject.h"
|
#include "../../objectmanager/SystemObject.h"
|
||||||
#include "../../tasks/ExecutableObjectIF.h"
|
#include "../../tasks/ExecutableObjectIF.h"
|
||||||
|
|
||||||
#ifdef __unix__
|
#ifdef PLATFORM_UNIX
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
#include "UdpTcPollingTask.h"
|
#include "UdpTcPollingTask.h"
|
||||||
#include "tcpipHelpers.h"
|
#include "tcpipHelpers.h"
|
||||||
|
#include "../../platform.h"
|
||||||
#include "../../globalfunctions/arrayprinter.h"
|
#include "../../globalfunctions/arrayprinter.h"
|
||||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef PLATFORM_WIN
|
||||||
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
#elif defined(PLATFORM_UNIX)
|
||||||
#else
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//! Debugging preprocessor define.
|
//! Debugging preprocessor define.
|
||||||
@ -155,7 +152,7 @@ ReturnValue_t UdpTcPollingTask::initializeAfterTaskCreation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UdpTcPollingTask::setTimeout(double timeoutSeconds) {
|
void UdpTcPollingTask::setTimeout(double timeoutSeconds) {
|
||||||
#ifdef _WIN32
|
#ifdef PLATFORM_WIN
|
||||||
DWORD timeoutMs = timeoutSeconds * 1000.0;
|
DWORD timeoutMs = timeoutSeconds * 1000.0;
|
||||||
int result = setsockopt(serverSocket, SOL_SOCKET, SO_RCVTIMEO,
|
int result = setsockopt(serverSocket, SOL_SOCKET, SO_RCVTIMEO,
|
||||||
reinterpret_cast<const char*>(&timeoutMs), sizeof(DWORD));
|
reinterpret_cast<const char*>(&timeoutMs), sizeof(DWORD));
|
||||||
@ -165,7 +162,7 @@ void UdpTcPollingTask::setTimeout(double timeoutSeconds) {
|
|||||||
"receive timeout failed with " << strerror(errno) << std::endl;
|
"receive timeout failed with " << strerror(errno) << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#elif defined(__unix__)
|
#elif defined(PLATFORM_UNIX)
|
||||||
timeval tval;
|
timeval tval;
|
||||||
tval = timevalOperations::toTimeval(timeoutSeconds);
|
tval = timevalOperations::toTimeval(timeoutSeconds);
|
||||||
int result = setsockopt(serverSocket, SOL_SOCKET, SO_RCVTIMEO,
|
int result = setsockopt(serverSocket, SOL_SOCKET, SO_RCVTIMEO,
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
|
#include "UdpTmTcBridge.h"
|
||||||
#include "tcpipHelpers.h"
|
#include "tcpipHelpers.h"
|
||||||
|
|
||||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
#include "../../platform.h"
|
||||||
#include <fsfw/ipc/MutexGuard.h>
|
#include "../../serviceinterface/ServiceInterface.h"
|
||||||
#include <fsfw/osal/common/UdpTmTcBridge.h>
|
#include "../../ipc/MutexGuard.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
|
#ifdef PLATFORM_WIN
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
#elif defined(PLATFORM_UNIX)
|
||||||
#elif defined(__unix__)
|
|
||||||
|
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//! Debugging preprocessor define.
|
//! Debugging preprocessor define.
|
||||||
|
@ -2,16 +2,13 @@
|
|||||||
#define FSFW_OSAL_WINDOWS_TMTCWINUDPBRIDGE_H_
|
#define FSFW_OSAL_WINDOWS_TMTCWINUDPBRIDGE_H_
|
||||||
|
|
||||||
#include "TcpIpBase.h"
|
#include "TcpIpBase.h"
|
||||||
|
#include "../../platform.h"
|
||||||
#include "../../tmtcservices/TmTcBridge.h"
|
#include "../../tmtcservices/TmTcBridge.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef PLATFORM_WIN
|
||||||
|
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
#elif defined(PLATFORM_UNIX)
|
||||||
#elif defined(__unix__)
|
|
||||||
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#include "../../serviceinterface/ServiceInterface.h"
|
#include "../../serviceinterface/ServiceInterface.h"
|
||||||
#include "../../timemanager/Clock.h"
|
#include "../../timemanager/Clock.h"
|
||||||
|
#include "../../platform.h"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#if defined(WIN32)
|
|
||||||
|
#if defined(PLATFORM_WIN)
|
||||||
#include <sysinfoapi.h>
|
#include <sysinfoapi.h>
|
||||||
#elif defined(LINUX)
|
#elif defined(PLATFORM_UNIX)
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -46,7 +48,7 @@ ReturnValue_t Clock::setClock(const timeval* time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Clock::getClock_timeval(timeval* time) {
|
ReturnValue_t Clock::getClock_timeval(timeval* time) {
|
||||||
#if defined(WIN32)
|
#if defined(PLATFORM_WIN)
|
||||||
auto now = std::chrono::system_clock::now();
|
auto now = std::chrono::system_clock::now();
|
||||||
auto secondsChrono = std::chrono::time_point_cast<std::chrono::seconds>(now);
|
auto secondsChrono = std::chrono::time_point_cast<std::chrono::seconds>(now);
|
||||||
auto epoch = now.time_since_epoch();
|
auto epoch = now.time_since_epoch();
|
||||||
@ -54,7 +56,7 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) {
|
|||||||
auto fraction = now - secondsChrono;
|
auto fraction = now - secondsChrono;
|
||||||
time->tv_usec = std::chrono::duration_cast<std::chrono::microseconds>(fraction).count();
|
time->tv_usec = std::chrono::duration_cast<std::chrono::microseconds>(fraction).count();
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
#elif defined(LINUX)
|
#elif defined(PLATFORM_UNIX)
|
||||||
timespec timeUnix;
|
timespec timeUnix;
|
||||||
int status = clock_gettime(CLOCK_REALTIME,&timeUnix);
|
int status = clock_gettime(CLOCK_REALTIME,&timeUnix);
|
||||||
if(status!=0){
|
if(status!=0){
|
||||||
@ -85,14 +87,14 @@ ReturnValue_t Clock::getClock_usecs(uint64_t* time) {
|
|||||||
|
|
||||||
timeval Clock::getUptime() {
|
timeval Clock::getUptime() {
|
||||||
timeval timeval;
|
timeval timeval;
|
||||||
#if defined(WIN32)
|
#if defined(PLATFORM_WIN)
|
||||||
auto uptime = std::chrono::milliseconds(GetTickCount64());
|
auto uptime = std::chrono::milliseconds(GetTickCount64());
|
||||||
auto secondsChrono = std::chrono::duration_cast<std::chrono::seconds>(uptime);
|
auto secondsChrono = std::chrono::duration_cast<std::chrono::seconds>(uptime);
|
||||||
timeval.tv_sec = secondsChrono.count();
|
timeval.tv_sec = secondsChrono.count();
|
||||||
auto fraction = uptime - secondsChrono;
|
auto fraction = uptime - secondsChrono;
|
||||||
timeval.tv_usec = std::chrono::duration_cast<std::chrono::microseconds>(
|
timeval.tv_usec = std::chrono::duration_cast<std::chrono::microseconds>(
|
||||||
fraction).count();
|
fraction).count();
|
||||||
#elif defined(LINUX)
|
#elif defined(PLATFORM_UNIX)
|
||||||
double uptimeSeconds;
|
double uptimeSeconds;
|
||||||
if (std::ifstream("/proc/uptime", std::ios::in) >> uptimeSeconds)
|
if (std::ifstream("/proc/uptime", std::ios::in) >> uptimeSeconds)
|
||||||
{
|
{
|
||||||
@ -119,7 +121,6 @@ ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) {
|
|||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
|
ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
|
||||||
/* Do some magic with chrono (C++20!) */
|
/* Do some magic with chrono (C++20!) */
|
||||||
/* Right now, the library doesn't have the new features to get the required values yet.
|
/* Right now, the library doesn't have the new features to get the required values yet.
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "taskHelpers.h"
|
#include "taskHelpers.h"
|
||||||
|
#include "../../platform.h"
|
||||||
#include "../../osal/host/FixedTimeslotTask.h"
|
#include "../../osal/host/FixedTimeslotTask.h"
|
||||||
#include "../../ipc/MutexFactory.h"
|
#include "../../ipc/MutexFactory.h"
|
||||||
#include "../../osal/host/Mutex.h"
|
#include "../../osal/host/Mutex.h"
|
||||||
@ -9,10 +10,10 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(PLATFORM_WIN)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "../windows/winTaskHelpers.h"
|
#include "../windows/winTaskHelpers.h"
|
||||||
#elif defined(LINUX)
|
#elif defined(PLATFORM_UNIX)
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "PeriodicTask.h"
|
#include "PeriodicTask.h"
|
||||||
#include "taskHelpers.h"
|
#include "taskHelpers.h"
|
||||||
|
|
||||||
|
#include "../../platform.h"
|
||||||
#include "../../ipc/MutexFactory.h"
|
#include "../../ipc/MutexFactory.h"
|
||||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||||
#include "../../tasks/ExecutableObjectIF.h"
|
#include "../../tasks/ExecutableObjectIF.h"
|
||||||
@ -9,10 +10,10 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(PLATFORM_WIN)
|
||||||
#include <processthreadsapi.h>
|
#include <processthreadsapi.h>
|
||||||
#include <fsfw/osal/windows/winTaskHelpers.h>
|
#include <fsfw/osal/windows/winTaskHelpers.h>
|
||||||
#elif defined(__unix__)
|
#elif defined(PLATFORM_UNIX)
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -24,9 +25,9 @@ PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority,
|
|||||||
// It is probably possible to set task priorities by using the native
|
// It is probably possible to set task priorities by using the native
|
||||||
// task handles for Windows / Linux
|
// task handles for Windows / Linux
|
||||||
mainThread = std::thread(&PeriodicTask::taskEntryPoint, this, this);
|
mainThread = std::thread(&PeriodicTask::taskEntryPoint, this, this);
|
||||||
#if defined(_WIN32)
|
#if defined(PLATFORM_WIN)
|
||||||
tasks::setTaskPriority(reinterpret_cast<HANDLE>(mainThread.native_handle()), setPriority);
|
tasks::setTaskPriority(reinterpret_cast<HANDLE>(mainThread.native_handle()), setPriority);
|
||||||
#elif defined(__unix__)
|
#elif defined(PLATFORM_UNIX)
|
||||||
// TODO: We could reuse existing code here.
|
// TODO: We could reuse existing code here.
|
||||||
#endif
|
#endif
|
||||||
tasks::insertTaskName(mainThread.get_id(), taskName);
|
tasks::insertTaskName(mainThread.get_id(), taskName);
|
||||||
|
10
platform.h
Normal file
10
platform.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#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_ */
|
@ -5,9 +5,9 @@
|
|||||||
#include "serviceInterfaceDefintions.h"
|
#include "serviceInterfaceDefintions.h"
|
||||||
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
#include "ServiceInterfaceStream.h"
|
||||||
#else
|
#else
|
||||||
#include <fsfw/serviceinterface/ServiceInterfacePrinter.h>
|
#include "ServiceInterfacePrinter.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* FSFW_SERVICEINTERFACE_SERVICEINTERFACE_H_ */
|
#endif /* FSFW_SERVICEINTERFACE_SERVICEINTERFACE_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user