eive-obsw/linux/payload/MpsocCommunication.h
Robin Mueller 65476f4c98
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
reduce printouts
2024-04-30 15:18:15 +02:00

45 lines
1.6 KiB
C++

#pragma once
#include <fsfw/objectmanager/SystemObject.h>
#include "eive/resultClassIds.h"
#include "fsfw/container/SimpleRingBuffer.h"
#include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
#include "linux/payload/SerialCommunicationHelper.h"
static constexpr bool MPSOC_LOW_LEVEL_TX_WIRETAPPING = false;
static constexpr bool MPSOC_LOW_LEVEL_RX_WIRETAPPING = false;
class MpsocCommunication : public SystemObject {
public:
static const uint8_t CLASS_ID = CLASS_ID::PLOC_MPSOC_COM;
static constexpr ReturnValue_t PACKET_RECEIVED = returnvalue::makeCode(CLASS_ID, 0);
static constexpr ReturnValue_t FAULTY_PACKET_SIZE = returnvalue::makeCode(CLASS_ID, 1);
static constexpr ReturnValue_t CRC_CHECK_FAILED = returnvalue::makeCode(CLASS_ID, 2);
MpsocCommunication(object_id_t objectId, SerialConfig cfg);
ReturnValue_t initialize() override;
ReturnValue_t send(const uint8_t* data, size_t dataLen);
// Should be called periodically to transfer the received data from the MPSoC from the Linux
// buffer to the internal ring buffer for further processing.
ReturnValue_t readSerialInterface();
// Parses the internal ring buffer for packets and checks whether a packet was received.
ReturnValue_t parseAndRetrieveNextPacket();
// Can be used to read the parse packet, if one was received.
const SpacePacketReader& getSpReader() const;
SerialCommunicationHelper& getComHelper();
private:
SpacePacketReader spReader;
uint8_t readBuf[4096];
SimpleRingBuffer readRingBuf;
SerialCommunicationHelper helper;
};