platform header file
This commit is contained in:
parent
d27f49c968
commit
1626b266d7
@ -1,10 +1,9 @@
|
||||
#include "TcpIpBase.h"
|
||||
#include "../../platform.h"
|
||||
|
||||
#ifdef __unix__
|
||||
|
||||
#ifdef PLATFORM_UNIX
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
#ifndef 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>
|
||||
|
||||
#elif defined(__unix__)
|
||||
#elif defined(PLATFORM_UNIX)
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
@ -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;
|
||||
|
@ -1,15 +1,13 @@
|
||||
#include "TcpTmTcServer.h"
|
||||
#include "tcpipHelpers.h"
|
||||
#include "../../platform.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef PLATFORM_WIN
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#elif defined(__unix__)
|
||||
|
||||
#elif defined(PLATFORM_UNIX)
|
||||
#include <netdb.h>
|
||||
|
||||
#endif
|
||||
|
||||
const std::string TcpTmTcServer::DEFAULT_TCP_SERVER_PORT = "7301";
|
||||
|
@ -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 <sys/socket.h>
|
||||
#endif
|
||||
|
||||
|
@ -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 <winsock2.h>
|
||||
|
||||
#else
|
||||
|
||||
#elif defined(PLATFORM_UNIX)
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#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<const char*>(&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,
|
||||
|
@ -1,18 +1,15 @@
|
||||
#include "UdpTmTcBridge.h"
|
||||
#include "tcpipHelpers.h"
|
||||
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <fsfw/ipc/MutexGuard.h>
|
||||
#include <fsfw/osal/common/UdpTmTcBridge.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "../../platform.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../ipc/MutexGuard.h"
|
||||
|
||||
#ifdef PLATFORM_WIN
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#elif defined(__unix__)
|
||||
|
||||
#elif defined(PLATFORM_UNIX)
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#endif
|
||||
|
||||
//! Debugging preprocessor define.
|
||||
|
@ -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 <ws2tcpip.h>
|
||||
|
||||
#elif defined(__unix__)
|
||||
|
||||
#elif defined(PLATFORM_UNIX)
|
||||
#include <sys/socket.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
@ -1,10 +1,12 @@
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../timemanager/Clock.h"
|
||||
#include "../../platform.h"
|
||||
|
||||
#include <chrono>
|
||||
#if defined(_WIN32)
|
||||
|
||||
#if defined(PLATFORM_WIN)
|
||||
#include <sysinfoapi.h>
|
||||
#elif defined(__unix__)
|
||||
#elif defined(PLATFORM_UNIX)
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
|
@ -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 <thread>
|
||||
#include <chrono>
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(PLATFORM_WIN)
|
||||
#include <windows.h>
|
||||
#include "../windows/winTaskHelpers.h"
|
||||
#elif defined(LINUX)
|
||||
#elif defined(PLATFORM_UNIX)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
|
@ -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 <thread>
|
||||
#include <chrono>
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(PLATFORM_WIN)
|
||||
#include <processthreadsapi.h>
|
||||
#include <fsfw/osal/windows/winTaskHelpers.h>
|
||||
#elif defined(__unix__)
|
||||
#elif defined(PLATFORM_UNIX)
|
||||
#include <pthread.h>
|
||||
#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<HANDLE>(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);
|
||||
|
Loading…
Reference in New Issue
Block a user