add modes
Some checks are pending
EIVE/eive-obsw/pipeline/head Build queued...
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2023-01-24 19:07:37 +01:00
parent b74db7b087
commit 8f8416c078
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
4 changed files with 70 additions and 3 deletions

View File

@ -150,7 +150,7 @@ set(OBSW_ADD_SCEX_DEVICE
${INIT_VAL}
CACHE STRING "Add Solar Cell Experiment module")
set(OBSW_SYRLINKS_SIMULATED
${OBSW_Q7S_EM}
0
CACHE STRING "Syrlinks is simulated")
# ##############################################################################

View File

@ -21,6 +21,7 @@ CcsdsIpCoreHandler::CcsdsIpCoreHandler(object_id_t objectId, object_id_t ptmeId,
tcDestination(tcDestination),
parameterHelper(this),
actionHelper(this, nullptr),
modeHelper(this),
ptmeConfig(ptmeConfig),
gpioIF(gpioIF),
enTxClock(enTxClock),
@ -152,6 +153,10 @@ void CcsdsIpCoreHandler::readCommandQueue(void) {
if (result == returnvalue::OK) {
return;
}
result = modeHelper.handleModeCommand(&commandMessage);
if (result == returnvalue::OK) {
return;
}
CommandMessage reply;
reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, commandMessage.getCommand());
commandQueue->reply(&reply);
@ -218,10 +223,12 @@ ReturnValue_t CcsdsIpCoreHandler::executeAction(ActionId_t actionId, MessageQueu
ReturnValue_t result = returnvalue::OK;
switch (actionId) {
case SET_LOW_RATE: {
submode = static_cast<Submode_t>(Submode::DATARATE_LOW);
result = ptmeConfig->setRate(RATE_100KBPS);
break;
}
case SET_HIGH_RATE: {
submode = static_cast<Submode_t>(Submode::DATARATE_HIGH);
result = ptmeConfig->setRate(RATE_500KBPS);
break;
}
@ -233,10 +240,16 @@ ReturnValue_t CcsdsIpCoreHandler::executeAction(ActionId_t actionId, MessageQueu
}
case EN_TRANSMITTER: {
enableTransmit();
if (mode == HasModesIF::MODE_OFF) {
mode = HasModesIF::MODE_ON;
}
return EXECUTION_FINISHED;
}
case DISABLE_TRANSMITTER: {
disableTransmit();
if (mode == HasModesIF::MODE_ON) {
mode = HasModesIF::MODE_OFF;
}
return EXECUTION_FINISHED;
}
case ENABLE_TX_CLK_MANIPULATOR: {
@ -339,6 +352,45 @@ void CcsdsIpCoreHandler::checkTxTimer() {
}
}
void CcsdsIpCoreHandler::getMode(Mode_t* mode, Submode_t* submode) {
*mode = this->mode;
*submode = this->submode;
}
ReturnValue_t CcsdsIpCoreHandler::checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t* msToReachTheMode) {
if (mode == HasModesIF::MODE_ON) {
if (submode != static_cast<Submode_t>(Submode::DATARATE_HIGH) and
submode != static_cast<Submode_t>(Submode::DATARATE_LOW)) {
return HasModesIF::INVALID_SUBMODE;
}
}
*msToReachTheMode = 2000;
return returnvalue::FAILED;
}
void CcsdsIpCoreHandler::startTransition(Mode_t mode, Submode_t submode) {
if (mode == HasModesIF::MODE_ON) {
enableTransmit();
if (submode == static_cast<Submode_t>(Submode::DATARATE_HIGH)) {
ReturnValue_t result = ptmeConfig->setRate(RATE_500KBPS);
if (result == returnvalue::OK) {
mode = HasModesIF::MODE_ON;
}
} else if (submode == static_cast<Submode_t>(Submode::DATARATE_LOW)) {
ReturnValue_t result = ptmeConfig->setRate(RATE_500KBPS);
if (result == returnvalue::OK) {
mode = HasModesIF::MODE_ON;
}
}
} else if (mode == HasModesIF::MODE_OFF) {
disableTransmit();
mode = HasModesIF::MODE_OFF;
}
}
void CcsdsIpCoreHandler::announceMode(bool recursive) { triggerEvent(MODE_INFO, mode, submode); }
void CcsdsIpCoreHandler::disableTransmit() {
#ifndef TE0720_1CFA
gpioIF->pullLow(enTxClock);

View File

@ -1,6 +1,8 @@
#ifndef CCSDSHANDLER_H_
#define CCSDSHANDLER_H_
#include <fsfw/modes/HasModesIF.h>
#include <cstdint>
#include <unordered_map>
@ -21,6 +23,8 @@
#include "fsfw_hal/common/gpio/gpioDefinitions.h"
#include "linux/ipcore/PtmeConfig.h"
enum class Submode : uint8_t { UNSET = 0, DATARATE_LOW = 1, DATARATE_HIGH = 2 };
/**
* @brief This class handles the data exchange with the CCSDS IP cores implemented in the
* programmable logic of the Q7S.
@ -32,6 +36,7 @@
*/
class CcsdsIpCoreHandler : public SystemObject,
public ExecutableObjectIF,
public HasModesIF,
public AcceptsTelemetryIF,
public AcceptsTelecommandsIF,
public ReceivesParameterMessagesIF,
@ -59,7 +64,14 @@ class CcsdsIpCoreHandler : public SystemObject,
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
ReturnValue_t initialize();
MessageQueueId_t getCommandQueue() const;
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;
/**
* @brief Function to add a virtual channel
@ -126,6 +138,9 @@ class CcsdsIpCoreHandler : public SystemObject,
ParameterHelper parameterHelper;
ActionHelper actionHelper;
Mode_t mode;
Submode_t submode = static_cast<Submode_t>(Submode::UNSET);
ModeHelper modeHelper;
MessageQueueId_t tcDistributorQueueId = MessageQueueIF::NO_QUEUE;

2
tmtc

@ -1 +1 @@
Subproject commit 49f27c9923cfa13a3bafce46c37dd2631550f4af
Subproject commit 49ccb4be8d42d6916be00ff9d8462a1f65481a6c