2019-12-26 19:47:46 +01:00
|
|
|
#ifndef FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_
|
|
|
|
#define FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_
|
|
|
|
|
2020-08-26 14:55:27 +02:00
|
|
|
|
2020-08-18 13:09:15 +02:00
|
|
|
#include "../objectmanager/SystemObject.h"
|
|
|
|
#include "../tmtcservices/AcceptsTelemetryIF.h"
|
|
|
|
#include "../tasks/ExecutableObjectIF.h"
|
|
|
|
#include "../ipc/MessageQueueIF.h"
|
|
|
|
#include "../storagemanager/StorageManagerIF.h"
|
|
|
|
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
2020-08-26 14:55:27 +02:00
|
|
|
#include "../container/DynamicFIFO.h"
|
2020-08-18 13:09:15 +02:00
|
|
|
#include "../tmtcservices/TmTcMessage.h"
|
2019-12-26 19:47:46 +01:00
|
|
|
|
|
|
|
class TmTcBridge : public AcceptsTelemetryIF,
|
2020-07-08 03:18:09 +02:00
|
|
|
public AcceptsTelecommandsIF,
|
2019-12-26 19:47:46 +01:00
|
|
|
public ExecutableObjectIF,
|
|
|
|
public HasReturnvaluesIF,
|
|
|
|
public SystemObject {
|
|
|
|
public:
|
2020-04-21 14:51:26 +02:00
|
|
|
static constexpr uint8_t TMTC_RECEPTION_QUEUE_DEPTH = 20;
|
2020-04-23 10:20:19 +02:00
|
|
|
static constexpr uint8_t LIMIT_STORED_DATA_SENT_PER_CYCLE = 15;
|
|
|
|
static constexpr uint8_t LIMIT_DOWNLINK_PACKETS_STORED = 20;
|
|
|
|
|
|
|
|
static constexpr uint8_t DEFAULT_STORED_DATA_SENT_PER_CYCLE = 5;
|
|
|
|
static constexpr uint8_t DEFAULT_DOWNLINK_PACKETS_STORED = 10;
|
2020-04-21 14:51:26 +02:00
|
|
|
|
2020-07-08 15:06:46 +02:00
|
|
|
TmTcBridge(object_id_t objectId, object_id_t tcDestination,
|
|
|
|
object_id_t tmStoreId, object_id_t tcStoreId);
|
2019-12-26 19:47:46 +01:00
|
|
|
virtual ~TmTcBridge();
|
|
|
|
|
|
|
|
/**
|
2020-04-21 14:51:26 +02:00
|
|
|
* Set number of packets sent per performOperation().Please note that this
|
|
|
|
* value must be smaller than MAX_STORED_DATA_SENT_PER_CYCLE
|
|
|
|
* @param sentPacketsPerCycle
|
|
|
|
* @return -@c RETURN_OK if value was set successfully
|
|
|
|
* -@c RETURN_FAILED otherwise, stored value stays the same
|
|
|
|
*/
|
|
|
|
ReturnValue_t setNumberOfSentPacketsPerCycle(uint8_t sentPacketsPerCycle);
|
|
|
|
|
2020-04-23 10:20:19 +02:00
|
|
|
/**
|
|
|
|
* Set number of packets sent per performOperation().Please note that this
|
|
|
|
* value must be smaller than MAX_DOWNLINK_PACKETS_STORED
|
|
|
|
* @param sentPacketsPerCycle
|
|
|
|
* @return -@c RETURN_OK if value was set successfully
|
|
|
|
* -@c RETURN_FAILED otherwise, stored value stays the same
|
|
|
|
*/
|
|
|
|
ReturnValue_t setMaxNumberOfPacketsStored(uint8_t maxNumberOfPacketsStored);
|
|
|
|
|
2020-08-26 14:55:27 +02:00
|
|
|
/**
|
|
|
|
* This will set up the bridge to overwrite old data in the FIFO.
|
|
|
|
* @param overwriteOld
|
|
|
|
*/
|
|
|
|
void setFifoToOverwriteOldData(bool overwriteOld);
|
|
|
|
|
2020-06-23 10:47:31 +02:00
|
|
|
virtual void registerCommConnect();
|
|
|
|
virtual void registerCommDisconnect();
|
2020-04-21 14:51:26 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes necessary FSFW components for the TMTC Bridge
|
2019-12-26 19:47:46 +01:00
|
|
|
* @return
|
|
|
|
*/
|
2020-06-23 10:47:31 +02:00
|
|
|
virtual ReturnValue_t initialize() override;
|
2019-12-26 19:47:46 +01:00
|
|
|
|
|
|
|
/**
|
2020-04-21 14:51:26 +02:00
|
|
|
* @brief Handles TMTC reception
|
2019-12-26 19:47:46 +01:00
|
|
|
*/
|
2020-06-23 10:47:31 +02:00
|
|
|
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
2019-12-26 19:47:46 +01:00
|
|
|
|
2020-07-08 03:18:09 +02:00
|
|
|
|
|
|
|
/** AcceptsTelemetryIF override */
|
2020-07-08 02:20:38 +02:00
|
|
|
virtual MessageQueueId_t getReportReceptionQueue(
|
2020-06-23 10:47:31 +02:00
|
|
|
uint8_t virtualChannel = 0) override;
|
2020-07-08 03:18:09 +02:00
|
|
|
|
|
|
|
/** AcceptsTelecommandsIF override */
|
|
|
|
virtual uint16_t getIdentifier() override;
|
|
|
|
virtual MessageQueueId_t getRequestQueue() override;
|
|
|
|
|
2019-12-26 19:47:46 +01:00
|
|
|
protected:
|
2020-07-08 15:06:46 +02:00
|
|
|
//! Cached for initialize function.
|
|
|
|
object_id_t tmStoreId = objects::NO_OBJECT;
|
|
|
|
object_id_t tcStoreId = objects::NO_OBJECT;
|
|
|
|
object_id_t tcDestination = objects::NO_OBJECT;
|
|
|
|
|
2020-04-18 13:16:00 +02:00
|
|
|
//! Used to send and receive TMTC messages.
|
2020-07-09 19:41:52 +02:00
|
|
|
//! The TmTcMessage class is used to transport messages between tasks.
|
2020-07-08 03:18:09 +02:00
|
|
|
MessageQueueIF* tmTcReceptionQueue = nullptr;
|
2020-07-08 15:06:46 +02:00
|
|
|
|
2020-04-18 13:16:00 +02:00
|
|
|
StorageManagerIF* tmStore = nullptr;
|
2020-07-08 15:06:46 +02:00
|
|
|
StorageManagerIF* tcStore = nullptr;
|
|
|
|
|
2020-07-09 19:41:52 +02:00
|
|
|
//! Used to specify whether communication link is up. Will be true
|
|
|
|
//! by default, so telemetry will be handled immediately.
|
2020-07-08 15:06:46 +02:00
|
|
|
bool communicationLinkUp = true;
|
2020-04-18 13:16:00 +02:00
|
|
|
bool tmStored = false;
|
2020-08-26 14:55:27 +02:00
|
|
|
bool overwriteOld = true;
|
|
|
|
uint8_t packetSentCounter = 0;
|
2019-12-26 19:47:46 +01:00
|
|
|
|
|
|
|
/**
|
2020-04-21 21:48:47 +02:00
|
|
|
* @brief Handle TC reception
|
|
|
|
* @details
|
|
|
|
* Default implementation provided, but is empty.
|
2020-07-08 03:18:09 +02:00
|
|
|
* In most cases, TC reception will be handled in a separate task anyway.
|
2019-12-26 19:47:46 +01:00
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
virtual ReturnValue_t handleTc();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle Telemetry. Default implementation provided.
|
|
|
|
* Calls sendTm()
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
virtual ReturnValue_t handleTm();
|
|
|
|
|
|
|
|
/**
|
2020-07-09 19:41:52 +02:00
|
|
|
* Read the TM Queue and send TM if necessary.
|
|
|
|
* Default implementation provided
|
2019-12-26 19:47:46 +01:00
|
|
|
* @return
|
|
|
|
*/
|
2020-04-23 10:20:19 +02:00
|
|
|
virtual ReturnValue_t handleTmQueue();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send stored data if communication link is active
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
virtual ReturnValue_t handleStoredTm();
|
2019-12-26 19:47:46 +01:00
|
|
|
|
|
|
|
/**
|
2019-12-26 20:38:15 +01:00
|
|
|
* Implemented by child class. Perform sending of Telemetry by implementing
|
2020-07-09 19:41:52 +02:00
|
|
|
* communication drivers or wrappers, e.g. serial communication or a socket
|
|
|
|
* call.
|
2019-12-26 19:47:46 +01:00
|
|
|
* @param data
|
|
|
|
* @param dataLen
|
|
|
|
* @return
|
|
|
|
*/
|
2020-04-21 14:51:26 +02:00
|
|
|
virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) = 0;
|
2019-12-26 19:47:46 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Store data to be sent later if communication link is not up.
|
|
|
|
* @param message
|
|
|
|
* @return
|
|
|
|
*/
|
2020-04-22 18:20:04 +02:00
|
|
|
virtual ReturnValue_t storeDownlinkData(TmTcMessage * message);
|
2019-12-26 19:47:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print data as hexidecimal array
|
|
|
|
* @param data
|
|
|
|
* @param dataLen
|
|
|
|
*/
|
2020-04-21 14:51:26 +02:00
|
|
|
void printData(uint8_t * data, size_t dataLen);
|
2019-12-26 19:47:46 +01:00
|
|
|
|
2020-04-23 12:47:59 +02:00
|
|
|
/**
|
|
|
|
* This fifo can be used to store downlink data
|
|
|
|
* which can not be sent at the moment.
|
|
|
|
*/
|
2020-08-26 14:55:27 +02:00
|
|
|
DynamicFIFO<store_address_t>* tmFifo = nullptr;
|
2020-04-23 12:47:59 +02:00
|
|
|
uint8_t sentPacketsPerCycle = DEFAULT_STORED_DATA_SENT_PER_CYCLE;
|
|
|
|
uint8_t maxNumberOfPacketsStored = DEFAULT_DOWNLINK_PACKETS_STORED;
|
2019-12-26 19:47:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_ */
|