eive-obsw/mission/tmtc/DirectTmSinkIF.h

58 lines
2.1 KiB
C
Raw Normal View History

2023-03-09 12:20:13 +01:00
#ifndef MISSION_TMTC_DIRECTTMSINKIF_H_
#define MISSION_TMTC_DIRECTTMSINKIF_H_
#include <cstddef>
2023-03-10 19:01:31 +01:00
#include "eive/resultClassIds.h"
2023-03-09 12:20:13 +01:00
#include "fsfw/retval.h"
class DirectTmSinkIF {
public:
virtual ~DirectTmSinkIF() = default;
2023-03-10 19:01:31 +01:00
static constexpr uint8_t CLASS_ID = CLASS_ID::TM_SINK;
static constexpr ReturnValue_t IS_BUSY = returnvalue::makeCode(CLASS_ID, 0);
2023-10-13 09:20:51 +02:00
static constexpr ReturnValue_t PARTIALLY_WRITTEN = returnvalue::makeCode(CLASS_ID, 1);
2023-10-13 15:24:06 +02:00
static constexpr ReturnValue_t NO_WRITE_ACTIVE = returnvalue::makeCode(CLASS_ID, 2);
2023-03-10 19:01:31 +01:00
2023-03-09 12:20:13 +01:00
/**
2023-10-13 15:24:06 +02:00
* @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.
2023-03-09 12:20:13 +01:00
*
* @param data Pointer to buffer holding the data to write
* @param size Number of bytes to write
2023-10-13 15:24:06 +02:00
* @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.
2023-03-09 12:20:13 +01:00
*/
2023-10-13 09:20:51 +02:00
virtual ReturnValue_t write(const uint8_t* data, size_t size, size_t& writtenSize) = 0;
2023-10-13 15:24:06 +02:00
/**
* 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.
2023-10-13 16:55:19 +02:00
* NO_WRITE_ACTIVE if this is called without a valid previous write call.
2023-10-13 15:24:06 +02:00
*/
2023-10-13 15:10:52 +02:00
virtual ReturnValue_t advanceWrite(size_t& writtenSize) = 0;
2023-03-10 18:04:04 +01:00
2023-10-13 16:55:19 +02:00
/**
* Is busy, so no write operation can not be started and write advancement
* is not possible.
* @return
*/
2023-03-10 18:04:04 +01:00
virtual bool isBusy() const = 0;
2023-10-13 15:24:06 +02:00
/**
* The PAPB interface is currently busy writing a packet and a new packet can not be written yet.
* @return
*/
virtual bool writeActive() const = 0;
2023-03-09 12:20:13 +01:00
};
#endif /* MISSION_TMTC_DIRECTTMSINKIF_H_ */