2021-09-19 12:27:48 +02:00
|
|
|
#ifndef CCSDSHANDLER_H_
|
|
|
|
#define CCSDSHANDLER_H_
|
|
|
|
|
2023-01-24 19:07:37 +01:00
|
|
|
#include <fsfw/modes/HasModesIF.h>
|
2023-03-09 17:44:05 +01:00
|
|
|
#include <mission/tmtc/VirtualChannelWithQueue.h>
|
2023-01-24 19:07:37 +01:00
|
|
|
|
2023-01-23 11:52:46 +01:00
|
|
|
#include <cstdint>
|
2022-01-17 15:58:27 +01:00
|
|
|
#include <unordered_map>
|
|
|
|
|
2021-09-26 08:29:30 +02:00
|
|
|
#include "OBSWConfig.h"
|
2023-01-23 11:52:46 +01:00
|
|
|
#include "eive/definitions.h"
|
2021-11-21 18:07:05 +01:00
|
|
|
#include "fsfw/action/ActionHelper.h"
|
|
|
|
#include "fsfw/action/HasActionsIF.h"
|
2021-11-22 18:01:16 +01:00
|
|
|
#include "fsfw/events/EventMessage.h"
|
2022-01-17 15:58:27 +01:00
|
|
|
#include "fsfw/objectmanager/SystemObject.h"
|
|
|
|
#include "fsfw/parameters/ParameterHelper.h"
|
2022-08-24 17:27:47 +02:00
|
|
|
#include "fsfw/returnvalues/returnvalue.h"
|
2023-01-27 15:10:26 +01:00
|
|
|
#include "fsfw/subsystem/ModeTreeConnectionIF.h"
|
2022-01-17 15:58:27 +01:00
|
|
|
#include "fsfw/tasks/ExecutableObjectIF.h"
|
|
|
|
#include "fsfw/timemanager/Countdown.h"
|
|
|
|
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
|
|
|
|
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
2021-11-22 18:01:16 +01:00
|
|
|
#include "fsfw_hal/common/gpio/GpioIF.h"
|
2022-01-17 15:58:27 +01:00
|
|
|
#include "fsfw_hal/common/gpio/gpioDefinitions.h"
|
2022-11-02 10:26:45 +01:00
|
|
|
#include "linux/ipcore/PtmeConfig.h"
|
2023-01-27 14:44:40 +01:00
|
|
|
#include "mission/comDefs.h"
|
2023-01-24 19:07:37 +01:00
|
|
|
|
2023-03-18 14:34:09 +01:00
|
|
|
struct PtmeGpios {
|
|
|
|
gpioId_t enableTxClock = gpio::NO_GPIO;
|
|
|
|
gpioId_t enableTxData = gpio::NO_GPIO;
|
|
|
|
gpioId_t ptmeResetn = gpio::NO_GPIO;
|
|
|
|
};
|
|
|
|
|
2021-09-19 12:27:48 +02:00
|
|
|
/**
|
|
|
|
* @brief This class handles the data exchange with the CCSDS IP cores implemented in the
|
|
|
|
* programmable logic of the Q7S.
|
|
|
|
*
|
2023-03-18 14:34:09 +01:00
|
|
|
* @details
|
|
|
|
* After reboot default CADU bitrate is always set to 100 kbps (results in downlink rate
|
|
|
|
* of 200 kbps due to convolutional code added by syrlinks transceiver). The IP core handler exposes
|
|
|
|
* a parameter to enable the priority selection mode for the PTME core.
|
|
|
|
*
|
|
|
|
* If the transmitter is on, the selection mode will be enabled when the transmitter goes off.
|
|
|
|
* If the transmitter is off, the update of the PTME will be done immediately on a parameter update.
|
|
|
|
* This is done because changing this parameter requires a reset of the PTME core to avoid bugs
|
|
|
|
* while the transmitter is enabled.
|
2022-01-24 07:43:14 +01:00
|
|
|
*
|
2021-09-19 12:27:48 +02:00
|
|
|
* @author J. Meier
|
|
|
|
*/
|
2022-11-02 10:26:45 +01:00
|
|
|
class CcsdsIpCoreHandler : public SystemObject,
|
|
|
|
public ExecutableObjectIF,
|
2023-01-27 15:10:26 +01:00
|
|
|
public ModeTreeChildIF,
|
|
|
|
public ModeTreeConnectionIF,
|
2023-01-24 19:07:37 +01:00
|
|
|
public HasModesIF,
|
2022-11-02 10:26:45 +01:00
|
|
|
public AcceptsTelecommandsIF,
|
|
|
|
public ReceivesParameterMessagesIF,
|
|
|
|
public HasActionsIF {
|
2022-01-17 15:58:27 +01:00
|
|
|
public:
|
2023-03-18 14:34:09 +01:00
|
|
|
enum ParamId : uint8_t { BAT_PRIORITY = 0 };
|
|
|
|
|
2023-03-09 17:44:05 +01:00
|
|
|
static const bool LINK_UP = true;
|
|
|
|
static const bool LINK_DOWN = false;
|
2022-01-17 15:58:27 +01:00
|
|
|
using VcId_t = uint8_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Constructor
|
|
|
|
*
|
|
|
|
* @param objectId Object ID of the CCSDS handler
|
|
|
|
* @param ptmeId Object ID of the PTME object providing access to the PTME IP Core.
|
|
|
|
* @param tcDestination Object ID of object handling received TC space packets
|
|
|
|
* @param txRateSetter Object providing the functionality to switch the input bitrate of
|
|
|
|
* the S-Band transceiver.
|
|
|
|
* @param gpioIF Required to enable TX data and TX clock RS485 transceiver chips.
|
|
|
|
* @param enTxClock GPIO ID of RS485 tx clock enable
|
|
|
|
* @param enTxData GPIO ID of RS485 tx data enable
|
|
|
|
*/
|
2023-03-09 17:44:05 +01:00
|
|
|
CcsdsIpCoreHandler(object_id_t objectId, object_id_t tcDestination, PtmeConfig& ptmeConfig,
|
2023-03-18 14:34:09 +01:00
|
|
|
std::atomic_bool& linkState, GpioIF* gpioIF, PtmeGpios gpioIds);
|
2022-01-17 15:58:27 +01:00
|
|
|
|
2022-11-02 10:26:45 +01:00
|
|
|
~CcsdsIpCoreHandler();
|
2022-01-17 15:58:27 +01:00
|
|
|
|
|
|
|
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
|
|
|
ReturnValue_t initialize();
|
2023-01-24 19:07:37 +01:00
|
|
|
MessageQueueId_t getCommandQueue() const override;
|
|
|
|
|
|
|
|
// ModesIF
|
|
|
|
void getMode(Mode_t* mode, Submode_t* submode) override;
|
|
|
|
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
|
|
|
uint32_t* msToReachTheMode) override;
|
|
|
|
void startTransition(Mode_t mode, Submode_t submode) override;
|
|
|
|
void announceMode(bool recursive) override;
|
2022-01-17 15:58:27 +01:00
|
|
|
|
|
|
|
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier,
|
|
|
|
ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues,
|
|
|
|
uint16_t startAtIndex);
|
|
|
|
|
2022-09-16 11:43:11 +02:00
|
|
|
uint32_t getIdentifier() const override;
|
|
|
|
MessageQueueId_t getRequestQueue() const override;
|
|
|
|
const char* getName() const override;
|
2022-01-17 15:58:27 +01:00
|
|
|
|
|
|
|
virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
|
|
|
const uint8_t* data, size_t size);
|
2023-01-27 15:10:26 +01:00
|
|
|
const HasHealthIF* getOptHealthIF() const override;
|
|
|
|
const HasModesIF& getModeIF() const override;
|
|
|
|
object_id_t getObjectId() const override;
|
|
|
|
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF& parent) override;
|
|
|
|
ModeTreeChildIF& getModeTreeChildIF() override;
|
2022-01-17 15:58:27 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER;
|
2022-05-12 18:32:19 +02:00
|
|
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER;
|
|
|
|
|
2023-01-23 11:52:46 +01:00
|
|
|
static const uint32_t QUEUE_SIZE = config::CCSDS_HANDLER_QUEUE_SIZE;
|
2022-01-17 15:58:27 +01:00
|
|
|
|
|
|
|
static const ActionId_t SET_LOW_RATE = 0;
|
|
|
|
static const ActionId_t SET_HIGH_RATE = 1;
|
|
|
|
static const ActionId_t EN_TRANSMITTER = 2;
|
2022-01-30 17:16:17 +01:00
|
|
|
static const ActionId_t DISABLE_TRANSMITTER = 3;
|
2022-01-25 18:55:52 +01:00
|
|
|
static const ActionId_t ARBITRARY_RATE = 4;
|
2022-01-30 17:16:17 +01:00
|
|
|
static const ActionId_t ENABLE_TX_CLK_MANIPULATOR = 5;
|
|
|
|
static const ActionId_t DISABLE_TX_CLK_MANIPULATOR = 6;
|
2022-04-01 14:15:42 +02:00
|
|
|
// Will update data with respect to tx clock signal of cadu bitstream on rising edge
|
2022-01-30 17:16:17 +01:00
|
|
|
static const ActionId_t UPDATE_ON_RISING_EDGE = 7;
|
2022-04-01 14:15:42 +02:00
|
|
|
// Will update data with respect to tx clock signal of cadu bitstream on falling edge
|
2022-01-30 17:16:17 +01:00
|
|
|
static const ActionId_t UPDATE_ON_FALLING_EDGE = 8;
|
2022-01-25 18:55:52 +01:00
|
|
|
|
|
|
|
// Syrlinks supports two bitrates (200 kbps and 1000 kbps)
|
|
|
|
// Due to convolutional code added by the syrlinks the input frequency must be half the
|
|
|
|
// target frequency
|
|
|
|
static const uint32_t RATE_100KBPS = 100000;
|
|
|
|
static const uint32_t RATE_500KBPS = 500000;
|
2022-01-17 15:58:27 +01:00
|
|
|
|
|
|
|
//! [EXPORT] : [COMMENT] Received action message with unknown action id
|
|
|
|
static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0);
|
2021-11-21 18:07:05 +01:00
|
|
|
|
2023-03-09 17:44:05 +01:00
|
|
|
// using VirtualChannelMap = std::unordered_map<VcId_t, VirtualChannelWithQueue*>;
|
|
|
|
// VirtualChannelMap virtualChannelMap;
|
|
|
|
std::atomic_bool& linkState;
|
2021-09-22 16:54:55 +02:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
object_id_t tcDestination;
|
2021-11-01 12:41:20 +01:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
MessageQueueIF* commandQueue = nullptr;
|
|
|
|
MessageQueueIF* eventQueue = nullptr;
|
|
|
|
ParameterHelper parameterHelper;
|
2021-09-26 08:29:30 +02:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
ActionHelper actionHelper;
|
2023-01-25 14:03:49 +01:00
|
|
|
Mode_t mode = HasModesIF::MODE_OFF;
|
2023-01-27 14:44:40 +01:00
|
|
|
Submode_t submode = static_cast<Submode_t>(com::CcsdsSubmode::UNSET);
|
2023-01-24 19:07:37 +01:00
|
|
|
ModeHelper modeHelper;
|
2021-11-21 18:07:05 +01:00
|
|
|
|
2022-02-19 16:42:22 +01:00
|
|
|
MessageQueueId_t tcDistributorQueueId = MessageQueueIF::NO_QUEUE;
|
2021-11-01 12:41:20 +01:00
|
|
|
|
2023-03-09 01:32:27 +01:00
|
|
|
PtmeConfig& ptmeConfig;
|
2023-03-18 14:34:09 +01:00
|
|
|
PtmeGpios ptmeGpios;
|
|
|
|
// BAT priority bit on by default to enable priority selection mode for the PTME.
|
2023-03-23 15:43:14 +01:00
|
|
|
uint8_t batPriorityParam = 0;
|
2023-03-18 14:34:09 +01:00
|
|
|
bool updateBatPriorityOnTxOff = false;
|
2021-11-21 18:07:05 +01:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
GpioIF* gpioIF = nullptr;
|
2022-03-26 14:08:34 +01:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
void readCommandQueue(void);
|
2021-11-22 18:01:16 +01:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
/**
|
|
|
|
* @brief Forward link state to virtual channels.
|
|
|
|
*/
|
2023-03-09 17:44:05 +01:00
|
|
|
void updateLinkState();
|
2021-11-22 18:01:16 +01:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
/**
|
|
|
|
* @brief Starts transmit timer and enables transmitter.
|
|
|
|
*/
|
|
|
|
void enableTransmit();
|
2021-11-22 18:01:16 +01:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
/**
|
|
|
|
* @brief Disables the transmitter by pulling the enable tx clock and tx data pin of the
|
|
|
|
* RS485 transceiver chips to high.
|
|
|
|
*/
|
|
|
|
void disableTransmit();
|
2023-03-18 14:34:09 +01:00
|
|
|
|
2023-03-18 14:40:07 +01:00
|
|
|
/**
|
2023-03-18 15:13:02 +01:00
|
|
|
* The following set of functions configure the mode of the PTME bandwith allocation table (BAT)
|
|
|
|
* module. This consists of the following 2 steps:
|
2023-03-18 14:40:07 +01:00
|
|
|
* 1. Update the BAT priority bit in the PTME wrapper
|
|
|
|
* 2. Reset the PTME as specified in the datasheet.
|
|
|
|
*/
|
2023-03-18 14:34:09 +01:00
|
|
|
void enablePrioritySelectMode();
|
|
|
|
void disablePrioritySelectMode();
|
|
|
|
void updateBatPriorityFromParam();
|
2021-09-19 12:27:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* CCSDSHANDLER_H_ */
|