eive-obsw/mission/tmtc/DirectTmSinkIF.h
Robin Mueller b8beddc11b
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
EIVE/eive-obsw/pipeline/pr-cfdp-source-handler This commit looks good
gens
2023-10-13 15:24:06 +02:00

52 lines
1.9 KiB
C++

#ifndef MISSION_TMTC_DIRECTTMSINKIF_H_
#define MISSION_TMTC_DIRECTTMSINKIF_H_
#include <cstddef>
#include "eive/resultClassIds.h"
#include "fsfw/retval.h"
class DirectTmSinkIF {
public:
virtual ~DirectTmSinkIF() = default;
static constexpr uint8_t CLASS_ID = CLASS_ID::TM_SINK;
static constexpr ReturnValue_t IS_BUSY = returnvalue::makeCode(CLASS_ID, 0);
static constexpr ReturnValue_t PARTIALLY_WRITTEN = returnvalue::makeCode(CLASS_ID, 1);
static constexpr ReturnValue_t NO_WRITE_ACTIVE = returnvalue::makeCode(CLASS_ID, 2);
/**
* @brief Implements the functionality to write to a TM sink directly.
*
* The write might not be completed immediately! If PARTIALLY_WRITTEN is returned, the user
* should poll the ready for packet status bit and call @advanceWrite continuously until
* the transfer is completed.
*
* @param data Pointer to buffer holding the data to write
* @param size Number of bytes to write
* @param writtenSize Size written during write call.
* @return returnvalue::OK on full write success, IS_BUSY if a previous write transfer has not
* been completed yet or the PAPB interface is not ready for a packet, PARTIALLY_WRITTEN
* if some bytes were written, but the transfer has not been completed yet.
*/
virtual ReturnValue_t write(const uint8_t* data, size_t size, size_t& writtenSize) = 0;
/**
* Advances a active file transfer.
* @param writtenSize
* @return returnvalue::OK if the packet write process is complete, PARTIALLY_WRITTEN if
* some bytes were written but the transfer is not complete yet.
*/
virtual ReturnValue_t advanceWrite(size_t& writtenSize) = 0;
virtual bool isBusy() const = 0;
/**
* The PAPB interface is currently busy writing a packet and a new packet can not be written yet.
* @return
*/
virtual bool writeActive() const = 0;
};
#endif /* MISSION_TMTC_DIRECTTMSINKIF_H_ */