fsfw/tmtcservices/TmTcBridge.h

130 lines
3.6 KiB
C
Raw Normal View History

2019-12-26 19:47:46 +01:00
/**
* @file TmTcBridge.h
*
* @date 26.12.2019
*/
#ifndef FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_
#define FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_
#include <framework/tmtcservices/AcceptsTelemetryIF.h>
#include <framework/tasks/ExecutableObjectIF.h>
#include <framework/ipc/MessageQueueIF.h>
#include <framework/storagemanager/StorageManagerIF.h>
#include <framework/objectmanager/SystemObject.h>
#include <framework/tmtcservices/TmTcMessage.h>
#include <framework/container/FIFO.h>
class TmTcBridge : public AcceptsTelemetryIF,
public ExecutableObjectIF,
public HasReturnvaluesIF,
public SystemObject {
public:
TmTcBridge(object_id_t objectId_, object_id_t ccsdsPacketDistributor_);
virtual ~TmTcBridge();
/**
2020-04-17 23:14:11 +02:00
* Initializes basic FSFW components for the TMTC Bridge
2019-12-26 19:47:46 +01:00
* @return
*/
virtual ReturnValue_t initialize();
/**
* @brief The performOperation method is executed in a task.
* @details There are no restrictions for calls within this method, so any
* other member of the class can be used.
* @return Currently, the return value is ignored.
*/
virtual ReturnValue_t performOperation(uint8_t operationCode = 0);
/**
* Return TMTC Reception Queue
* @param virtualChannel
* @return
*/
virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0);
void registerCommConnect();
void registerCommDisconnect();
2019-12-26 19:47:46 +01:00
protected:
//! Used to send and receive TMTC messages.
//! TmTcMessage is used to transport messages between tasks.
MessageQueueIF* TmTcReceptionQueue = nullptr;
StorageManagerIF* tcStore = nullptr;
StorageManagerIF* tmStore = nullptr;
object_id_t ccsdsPacketDistributor = 0;
//! Used to specify whether communication link is up
bool communicationLinkUp = false;
bool tmStored = false;
2019-12-26 19:47:46 +01:00
/**
* Handle TC reception. Default implementation provided
* @return
*/
virtual ReturnValue_t handleTc();
/**
* Implemented by child class. Perform receiving of Telecommand, for example by implementing
* specific drivers or wrappers, e.g. UART Communication or lwIP stack
2020-04-17 23:17:32 +02:00
* @param recvBuffer [out] Received data
* @param size [out] Size of received data
2019-12-26 19:47:46 +01:00
* @return
*/
2020-04-17 23:17:32 +02:00
virtual ReturnValue_t receiveTc(uint8_t ** recvBuffer, uint32_t * size) = 0;
2019-12-26 19:47:46 +01:00
/**
* Handle Telemetry. Default implementation provided.
* Calls sendTm()
* @return
*/
virtual ReturnValue_t handleTm();
/**
* Read the TM Queue and send TM if necessary. Default implementation provided
* @return
*/
virtual ReturnValue_t readTmQueue();
/**
* Implemented by child class. Perform sending of Telemetry by implementing
* communication drivers or wrappers, e.g. UART communication or lwIP stack.
2019-12-26 19:47:46 +01:00
* @param data
* @param dataLen
* @return
*/
virtual ReturnValue_t sendTm(const uint8_t * data, uint32_t dataLen) = 0;
/**
* Store data to be sent later if communication link is not up.
* @param message
* @return
*/
ReturnValue_t storeDownlinkData(TmTcMessage * message);
/**
* Send stored data if communication link is active
* @return
*/
ReturnValue_t sendStoredTm();
/**
* Print data as hexidecimal array
* @param data
* @param dataLen
*/
void printData(uint8_t * data, uint32_t dataLen);
private:
static constexpr uint8_t TMTC_RECEPTION_QUEUE_DEPTH = 20;
static constexpr uint8_t MAX_STORED_DATA_SENT_PER_CYCLE = 10;
static constexpr uint8_t MAX_DOWNLINK_PACKETS_STORED = 15;
2019-12-26 19:47:46 +01:00
FIFO<store_address_t, MAX_DOWNLINK_PACKETS_STORED> fifo;
uint8_t * recvBuffer = nullptr;
uint32_t size = 0;
2019-12-26 19:47:46 +01:00
};
#endif /* FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_ */