migrate fully to freeRTOS

This commit is contained in:
2025-02-15 22:21:19 +01:00
parent 4e94d7ad78
commit c13310d540
22 changed files with 226 additions and 410 deletions
+9 -17
View File
@@ -18,6 +18,9 @@
#include "SAD_DetectedServer.h"
#include <string>
#include <list>
#include "Mutex.hpp"
#include "Semaphore.hpp"
#include "Task.hpp"
static const string SERVERAUTODETECT_PRECODE = "#SAD#";
@@ -25,39 +28,28 @@ static const string SERVERAUTODETECT_SEPERATOR = "#,#";
static const string SERVERAUTODETECT_TASKID = "#spit#";
static const string SERVERAUTODETECT_PORT = "15110";
class SAD_Client {
//----- SAD Client Interface ------
private:
static recursive_mutex s_MutexClientInterface;
static SAD_ClientInterface* s_SADClientInterface;
//----- SAD_Client -----
public:
private:
static mutex s_MutexSAD;
static condition_variable s_ConditionStopSAD;
static fos::Mutex s_MutexSAD;
static fos::Semaphore s_ConditionStopSAD;
static bool s_StopSAD;
static thread* s_ThreadSend;
static thread* s_ThreadReceiveIP4;
static thread* s_ThreadReceiveIP6;
static fos::Task* s_ThreadSend;
static fos::Task* s_ThreadReceiveIP4;
static recursive_mutex s_MutexSocket;
static fos::Mutex s_MutexSocket;
static SPITSocket* s_SPITSocket;
static void sendAutoDetectServer();
static void cycleStart();
static void cycleEnd();
static void sendAutoDetectServer();
static void receiveAutoDetectServer_IP4();
static void receiveAutoDetectServer_IP6();
public:
static void startAutoDetectServer(SAD_ClientInterface* p_SADClientInterface, SPITSocket* p_SPITSocket);
+3 -3
View File
@@ -17,7 +17,7 @@
#include "SAD_ClientInterface.h"
#include <string>
#include <mutex>
#include "Mutex.hpp"
#include <unordered_map>
#include <list>
@@ -175,7 +175,7 @@ private:
}
private:
static recursive_mutex s_MutexDetectedServer;
static fos::Mutex s_MutexDetectedServer;
static unordered_map<string, SAD_DetectedServer*> s_DetectedServers;
public:
static const int PARAMINDEX_PRECODE = 0;
@@ -222,7 +222,7 @@ public:
static const SAD_DetectedServer& getRefDetectedServer(string p_ServerID) {
SAD_DetectedServer* ptrDetectedServer = NULL;
{
unique_lock<recursive_mutex> o_Lock(s_MutexDetectedServer);
fos::MutexGuard o_Lock(s_MutexDetectedServer);
auto i = s_DetectedServers.find(p_ServerID);
if (i != s_DetectedServers.end()) {
ptrDetectedServer = i->second;
+3 -4
View File
@@ -14,12 +14,11 @@
#ifndef SPITOBJECT_H
#define SPITOBJECT_H
//#include "_SPITMACROS.h"
#include "SPIT_Message.h"
#include "SPITType.h"
#include <string>
#include <unordered_map>
#include <mutex>
#include "Mutex.hpp"
using namespace std;
@@ -28,11 +27,11 @@ class SPITObjectListener;
class SPITObject {
private:
static recursive_mutex s_MutexSPITObject;
static fos::Mutex s_MutexSPITObject;
static unordered_map<string, SPITObject*> s_SPITObjects;
static unordered_map<string, SPITObject*> s_SPITObjectsRemote;
public:
static recursive_mutex* getMutex() {
static fos::Mutex* getMutex() {
return &s_MutexSPITObject;
}
static SPITObject* getSPITObject(string p_ID);
+2 -2
View File
@@ -119,8 +119,8 @@ public:
//----- SPITPlayer ------
public:
static recursive_mutex s_Mutex;
static recursive_mutex* getMutex() {
static fos::Mutex s_Mutex;
static fos::Mutex* getMutex() {
return &s_Mutex;
}
//list the SPITPlayers
+3 -3
View File
@@ -16,7 +16,7 @@
#ifndef SPITSOCKET_H
#define SPITSOCKET_H
#include "_SPITMACROS.h"
#include <mutex>
#include "Mutex.hpp"
#include <unordered_map>
#include <string>
@@ -59,7 +59,7 @@ public:
};
private:
static recursive_mutex s_MutexIPAddresses;
static fos::Mutex s_MutexIPAddresses;
public:
static unordered_map<string, IPAddress*> s_IPAddresses;
static void addIPAddress(string p_IPAddress, string p_SubnetMask);
@@ -83,7 +83,7 @@ private:
string m_BoundClientPort; //port set after bind
int m_BoundClientFamily;
bool m_IsBound;
recursive_mutex m_MutexSocket;
fos::Mutex m_MutexSocket;
public:
/**
* Sets the ip address and port for server and client.
+3 -3
View File
@@ -18,7 +18,7 @@
#include "SPIT_Message.h"
#include <string>
#include <unordered_map>
#include <mutex>
#include "Mutex.hpp"
using namespace std;
@@ -27,14 +27,14 @@ class SPITTypeListener;
class SPITType {
private:
static recursive_mutex s_MutexSPITType;
static fos::Mutex s_MutexSPITType;
static unordered_map<string, SPITType*> s_SPITTypes;
static unordered_map<string, SPITType*> s_SPITTypesRemote;
public:
static recursive_mutex* getMutex() {
static fos::Mutex* getMutex() {
return &s_MutexSPITType;
}
static SPITType* getSPITType(string p_ID);
+3 -4
View File
@@ -29,7 +29,6 @@
#include "SPIT_Handler.h"
#include "SPITPlayer.h"
#include <chrono>
using namespace std;
//static char nullChar[] = "\0";
@@ -81,8 +80,8 @@ private:
/** SPITClientInterface, normally the user app should implement this*/
SPIT_ClientInterface* m_SPITClientInterface;
SPITSocket* m_SPITSocket;
recursive_mutex m_MutexSPITSocket;
thread* m_ThreadReceive;
fos::Mutex m_MutexSPITSocket;
fos::TaskT<SPIT_Client&> * m_ThreadReceive;
bool m_StopReceiveSPITMessages;
int m_ConnectionStatus;
@@ -153,7 +152,7 @@ public:
private:
bool startReceiveSPITMessages();
void stopReceiveSPITMessages();
void receiveSPITMessage();
static void receiveSPITMessage(SPIT_Client& rM);
int sendSPITMessage(SPIT_Message::OPPart* p_SPITMessageOPPart);
void fillHeader(SPIT_Message::Header* p_Header);
+6 -6
View File
@@ -14,9 +14,9 @@
#ifndef SPIT_HANDLER_H
#define SPIT_HANDLER_H
#include <mutex>
#include <condition_variable>
#include <thread>
#include "Mutex.hpp"
#include "Semaphore.hpp"
#include "Task.hpp"
#include <list>
using namespace std;
@@ -32,9 +32,9 @@ public:
private:
static list<Runnable*> s_Runnables;
static mutex s_MutexLock;
static condition_variable s_ConditionVariable;
static thread s_HandlerThread;
static fos::Mutex s_MutexLock;
static fos::Semaphore s_ConditionVariable;
static fos::Task* s_HandlerThread;
static bool s_WakeUp;
static bool s_Close;
-1
View File
@@ -22,7 +22,6 @@
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <thread>
#include "SPITSocket.h"
+8 -8
View File
@@ -15,9 +15,9 @@
#define WATCHDOG_H
#include "_SPITMACROS.h"
#include <mutex>
#include <condition_variable>
#include <thread>
#include "Mutex.hpp"
#include "Semaphore.hpp"
#include "Task.hpp"
using namespace std;
@@ -37,15 +37,15 @@ public:
virtual ~Watchdog();
private:
Listener* m_Listener;
Listener* m_Listener;
mutex m_MutexLock;
condition_variable m_ConditionVariable;
thread* m_WatchdogThread;
fos::Mutex m_MutexLock;
fos::Semaphore m_ConditionVariable;
fos::TaskT<Watchdog&>* m_WatchdogThread;
bool m_Answered;
void runWatchdog();
static void runWatchdog(Watchdog& wd);
public:
void startWatchdog();
void answerWatchdog();
-3
View File
@@ -5,9 +5,6 @@
// To output debug information (printf calls in the code)
// you must set or comment out this precompiler definition
#ifndef DEBUGOUTPUT
#define DEBUGOUTPUT
#endif
#include <string>
using namespace std;