1
0
forked from fsfw/fsfw

TCP server implementation finished

A lot of smaller tweaks and smaller refactoring done
in UDP TMTC bridge as well
This commit is contained in:
2021-05-05 15:59:41 +02:00
parent 126def219b
commit c1d30aad13
11 changed files with 152 additions and 65 deletions

View File

@ -17,16 +17,30 @@
#include <string>
/**
* @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;