ccsds handler wip
This commit is contained in:
110
mission/tmtc/VirtualChannel.h
Normal file
110
mission/tmtc/VirtualChannel.h
Normal file
@ -0,0 +1,110 @@
|
||||
#ifndef VIRTUALCHANNEL_H_
|
||||
#define VIRTUALCHANNEL_H_
|
||||
|
||||
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include <fsfw/ipc/MessageQueueIF.h>
|
||||
|
||||
#include <framework/ipc/MessageQueue.h>
|
||||
#include <framework/objectmanager/SystemObject.h>
|
||||
#include <framework/osal/OSAL.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/storagemanager/StorageManagerIF.h>
|
||||
#include <framework/timemanager/Countdown.h>
|
||||
#include <framework/tmtcpacket/SpacePacket.h>
|
||||
#include <framework/tmtcservices/AcceptsTelemetryIF.h>
|
||||
#include <mission/obc/ccsdsboard/BoardHandler.h>
|
||||
|
||||
/**
|
||||
* @brief This class represents a virtual channel in the software.
|
||||
*
|
||||
* @author J. Meier
|
||||
*/
|
||||
class VirtualChannel: public AcceptsTelemetryIF, public HasReturnvaluesIF {
|
||||
public:
|
||||
|
||||
uint32_t tmSendLimitPerCycle; //!< Current maximum bytes per cycle.
|
||||
|
||||
static const uint32_t IDLE_INTERVAL_RT_CHANNEL = 2000; //!< Real Time channel (VC 0) idle interval.
|
||||
|
||||
static const uint16_t IDLE_PACKET_SIZE = 1015; //!< Size of generated idle packets.
|
||||
|
||||
static const uint32_t DEFAULT_IDLE_INTERVAL = 20000; //!< Default if too lazy to set.
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param vcId The virtual channel id assigned to this object
|
||||
* @param tmQueueDepth Queue depth of queue receiving telemetry from other objects
|
||||
*/
|
||||
VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth);
|
||||
|
||||
ReturnValue_t initialize();
|
||||
|
||||
/**
|
||||
* One of the main public methods.
|
||||
* Checks the tmQueue, calls #handlePacket if packets were found and keeps track of the number of sent bytes,
|
||||
* to stop transmission before a buffer overflow occurs. If no packets were sent, an idle packet is generated.
|
||||
* @return Number of sent bytes. 0 if an error occurred.
|
||||
*/
|
||||
uint32_t packetProcessing(void);
|
||||
/**
|
||||
* Another important method to check successful forwarding of packets.
|
||||
* Checks how many packets have been forwarded to the CCSDS Board and tries to get as many
|
||||
* RMAP write replys. The pending messages are deleted here.
|
||||
* @return @c RETURN_OK on success, or one of many error codes, mainly coming from @c receiveVCAcknowledge.
|
||||
*/
|
||||
ReturnValue_t packetProcessingCheck(void);
|
||||
/**
|
||||
* Setter.
|
||||
* @param setStore Sets the #packetStore used.
|
||||
*/
|
||||
void setPacketStore(StorageManagerIF* setStore);
|
||||
MessageQueueId_t getReportReceptionQueue();
|
||||
|
||||
ReturnValue_t performOperation();
|
||||
|
||||
/**
|
||||
* @brief Sets the PTME object which handles access to the PTME IP Core.
|
||||
*
|
||||
* @param ptme Pointer to ptme object
|
||||
*/
|
||||
void setPtmeObject(Ptme* ptme);
|
||||
|
||||
private:
|
||||
|
||||
PtmeIF* ptme = nullptr;
|
||||
MessageQueueIF* tmQueue = nullptr;
|
||||
uint8_t virtualChannelId;
|
||||
bool linkIsUp;
|
||||
StorageManagerIF* tmStore = nullptr;
|
||||
|
||||
|
||||
BoardHandler* boardHandler; //!< A reference to the "hardware part" of handling the packets.
|
||||
store_address_t pendingTm[BoardHandler::TM_PACKETS_PER_CALL_PER_CHANNEL]; //!< List of packets sent to the board. Is used to check if all Space Packets sent received the CCSDS Board.
|
||||
uint16_t sendCount; //!< Counter to identify how many packets have been sent coming in to the board (without Idle Packets).
|
||||
Countdown timer;
|
||||
SpacePacket idlePacket;
|
||||
uint32_t accumulatedByteCount;
|
||||
|
||||
store_address_t pendingPacket;
|
||||
|
||||
static const uint32_t TM_SEND_LIMIT_PER_CYCLE = 1300; //!< The maximum number of bytes to send to the CCSDS Board VC per cycle.
|
||||
|
||||
/**
|
||||
* Helper method to send an idle packet.
|
||||
* @return @c RETURN_OK on success, @c RETURN_FAILED otherwise.
|
||||
*/
|
||||
ReturnValue_t sendIdlePacket(uint32_t size);
|
||||
/**
|
||||
* A helper method to handle incoming packets.
|
||||
* Reads a packet from #packetStore and tries to forward it to the CCSDS BoardHandler class.
|
||||
* Calls the hardware layer with @c writeToVc. Depending on what the "hardware" layer does,
|
||||
* it stores the sent packet id's to find out if they were all received by the CCSDS Board.
|
||||
* @param store_id ID of a packet in the #packetStore.
|
||||
* @return @c RETURN_OK on success, the return code of @c writeToVc otherwise.
|
||||
*/
|
||||
ReturnValue_t handlePacket(store_address_t storeId);
|
||||
};
|
||||
|
||||
#endif /* VIRTUALCHANNEL_H_ */
|
Reference in New Issue
Block a user