ccsds handler sending command to enable transmitter
This commit is contained in:
parent
3c3884476b
commit
919141ae10
@ -91,7 +91,7 @@
|
|||||||
#include "mission/system/AcsBoardAssembly.h"
|
#include "mission/system/AcsBoardAssembly.h"
|
||||||
#include "mission/tmtc/CCSDSHandler.h"
|
#include "mission/tmtc/CCSDSHandler.h"
|
||||||
#include "mission/tmtc/VirtualChannel.h"
|
#include "mission/tmtc/VirtualChannel.h"
|
||||||
#include "mission/utility/TmFunnel.h"
|
#include "mission/tmtc/TmFunnel.h"
|
||||||
|
|
||||||
ResetArgs resetArgsGnss0;
|
ResetArgs resetArgsGnss0;
|
||||||
ResetArgs resetArgsGnss1;
|
ResetArgs resetArgsGnss1;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "linux/obc/PtmeConfig.h"
|
#include "linux/obc/PtmeConfig.h"
|
||||||
#include "mission/core/GenericFactory.h"
|
#include "mission/core/GenericFactory.h"
|
||||||
#include "mission/devices/Tmp1075Handler.h"
|
#include "mission/devices/Tmp1075Handler.h"
|
||||||
#include "mission/utility/TmFunnel.h"
|
#include "mission/tmtc/TmFunnel.h"
|
||||||
#include "mission/tmtc/CCSDSHandler.h"
|
#include "mission/tmtc/CCSDSHandler.h"
|
||||||
#include "mission/tmtc/VirtualChannel.h"
|
#include "mission/tmtc/VirtualChannel.h"
|
||||||
#include "objects/systemObjectList.h"
|
#include "objects/systemObjectList.h"
|
||||||
|
@ -190,15 +190,22 @@ bool PdecHandler::newTcReceived() {
|
|||||||
|
|
||||||
void PdecHandler::checkLocks() {
|
void PdecHandler::checkLocks() {
|
||||||
uint32_t clcw = getClcw();
|
uint32_t clcw = getClcw();
|
||||||
if (!(clcw & NO_RF_MASK) && (lastClcw & NO_RF_MASK)) {
|
if (not (clcw & NO_RF_MASK) && not carrierLock) {
|
||||||
// Rf available changed from 0 to 1
|
|
||||||
triggerEvent(CARRIER_LOCK);
|
triggerEvent(CARRIER_LOCK);
|
||||||
|
carrierLock = true;
|
||||||
}
|
}
|
||||||
if (!(clcw & NO_BITLOCK_MASK) && (lastClcw & NO_BITLOCK_MASK)) {
|
else if ((clcw & NO_RF_MASK) && carrierLock) {
|
||||||
// Bit lock changed from 0 to 1
|
carrierLock = false;
|
||||||
|
triggerEvent(LOST_CARRIER_LOCK_PDEC);
|
||||||
|
}
|
||||||
|
if (not (clcw & NO_BITLOCK_MASK) && not bitLock) {
|
||||||
triggerEvent(BIT_LOCK_PDEC);
|
triggerEvent(BIT_LOCK_PDEC);
|
||||||
|
bitLock = true;
|
||||||
|
}
|
||||||
|
else if ((clcw & NO_BITLOCK_MASK) && bitLock) {
|
||||||
|
bitLock = false;
|
||||||
|
triggerEvent(LOST_BIT_LOCK_PDEC);
|
||||||
}
|
}
|
||||||
lastClcw = clcw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PdecHandler::checkFrameAna(uint32_t pdecFar) {
|
bool PdecHandler::checkFrameAna(uint32_t pdecFar) {
|
||||||
|
@ -73,6 +73,10 @@ class PdecHandler : public SystemObject,
|
|||||||
static const Event CARRIER_LOCK = MAKE_EVENT(3, severity::INFO);
|
static const Event CARRIER_LOCK = MAKE_EVENT(3, severity::INFO);
|
||||||
//! [EXPORT] : [COMMENT] Bit lock detected (data valid)
|
//! [EXPORT] : [COMMENT] Bit lock detected (data valid)
|
||||||
static const Event BIT_LOCK_PDEC = MAKE_EVENT(4, severity::INFO);
|
static const Event BIT_LOCK_PDEC = MAKE_EVENT(4, severity::INFO);
|
||||||
|
//! [EXPORT] : [COMMENT] Lost carrier lock
|
||||||
|
static const Event LOST_CARRIER_LOCK_PDEC = MAKE_EVENT(5, severity::INFO);
|
||||||
|
//! [EXPORT] : [COMMENT] Lost bit lock
|
||||||
|
static const Event LOST_BIT_LOCK_PDEC = MAKE_EVENT(6, severity::INFO);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER;
|
static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER;
|
||||||
@ -391,6 +395,9 @@ class PdecHandler : public SystemObject,
|
|||||||
|
|
||||||
// Used to check carrier and bit lock changes (default set to no rf and no bitlock)
|
// Used to check carrier and bit lock changes (default set to no rf and no bitlock)
|
||||||
uint32_t lastClcw = 0xC000;
|
uint32_t lastClcw = 0xC000;
|
||||||
|
|
||||||
|
bool carrierLock = false;
|
||||||
|
bool bitLock = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* LINUX_OBC_PDECHANDLER_H_ */
|
#endif /* LINUX_OBC_PDECHANDLER_H_ */
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <fsfw/tcdistribution/CCSDSDistributor.h>
|
#include <fsfw/tcdistribution/CCSDSDistributor.h>
|
||||||
#include <fsfw/tcdistribution/PUSDistributor.h>
|
#include <fsfw/tcdistribution/PUSDistributor.h>
|
||||||
#include <fsfw/timemanager/TimeStamper.h>
|
#include <fsfw/timemanager/TimeStamper.h>
|
||||||
#include <mission/utility/TmFunnel.h>
|
#include <mission/tmtc/TmFunnel.h>
|
||||||
|
|
||||||
#include "OBSWConfig.h"
|
#include "OBSWConfig.h"
|
||||||
#include "eive/definitions.h"
|
#include "eive/definitions.h"
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_
|
#define MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_
|
||||||
|
|
||||||
#include <commonSubsystemIds.h>
|
#include <commonSubsystemIds.h>
|
||||||
|
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||||
|
|
||||||
namespace syrlinks {
|
namespace syrlinks {
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
#include "fsfw/serviceinterface/serviceInterfaceDefintions.h"
|
#include "fsfw/serviceinterface/serviceInterfaceDefintions.h"
|
||||||
|
|
||||||
|
#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h"
|
||||||
|
|
||||||
CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination,
|
CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination,
|
||||||
PtmeConfig* ptmeConfig, GpioIF* gpioIF, gpioId_t enTxClock,
|
PtmeConfig* ptmeConfig, GpioIF* gpioIF, gpioId_t enTxClock,
|
||||||
gpioId_t enTxData, uint32_t transmitterTimeout)
|
gpioId_t enTxData, uint32_t transmitterTimeout)
|
||||||
@ -22,11 +24,14 @@ CCSDSHandler::CCSDSHandler(object_id_t objectId, object_id_t ptmeId, object_id_t
|
|||||||
gpioIF(gpioIF),
|
gpioIF(gpioIF),
|
||||||
enTxClock(enTxClock),
|
enTxClock(enTxClock),
|
||||||
enTxData(enTxData),
|
enTxData(enTxData),
|
||||||
transmitterTimeout(transmitterTimeout) {
|
transmitterTimeout(transmitterTimeout),
|
||||||
|
commandActionHelper(this) {
|
||||||
commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE);
|
commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE);
|
||||||
auto mqArgs = MqArgs(objectId, static_cast<void*>(this));
|
auto mqArgs = MqArgs(objectId, static_cast<void*>(this));
|
||||||
eventQueue =
|
eventQueue =
|
||||||
QueueFactory::instance()->createMessageQueue(10, EventMessage::EVENT_MESSAGE_SIZE, &mqArgs);
|
QueueFactory::instance()->createMessageQueue(10, EventMessage::EVENT_MESSAGE_SIZE, &mqArgs);
|
||||||
|
commandActionHelperQueue =
|
||||||
|
QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSDSHandler::~CCSDSHandler() {}
|
CCSDSHandler::~CCSDSHandler() {}
|
||||||
@ -120,6 +125,10 @@ ReturnValue_t CCSDSHandler::initialize() {
|
|||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
#if OBSW_SYRLINKS_SIMULATED == 1
|
#if OBSW_SYRLINKS_SIMULATED == 1
|
||||||
ptmeConfig->invertTxClock(true);
|
ptmeConfig->invertTxClock(true);
|
||||||
#endif /* OBSW_SYRLINKS_SIMULATED == 1*/
|
#endif /* OBSW_SYRLINKS_SIMULATED == 1*/
|
||||||
@ -148,8 +157,73 @@ void CCSDSHandler::readCommandQueue(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCSDSHandler::readCommandActionHelperQueue() {
|
||||||
|
CommandMessage message;
|
||||||
|
for (ReturnValue_t result = commandActionHelperQueue->receiveMessage(&message);
|
||||||
|
result == RETURN_OK; result = commandActionHelperQueue->receiveMessage(&message)) {
|
||||||
|
result = commandActionHelper.handleReply(&message);
|
||||||
|
if (result == RETURN_OK) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MessageQueueId_t CCSDSHandler::getCommandQueue() const { return commandQueue->getId(); }
|
MessageQueueId_t CCSDSHandler::getCommandQueue() const { return commandQueue->getId(); }
|
||||||
|
|
||||||
|
MessageQueueIF* CCSDSHandler::getCommandQueuePtr() { return commandActionHelperQueue; }
|
||||||
|
|
||||||
|
void CCSDSHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { return; }
|
||||||
|
|
||||||
|
void CCSDSHandler::stepFailedReceived(ActionId_t actionId, uint8_t step,
|
||||||
|
ReturnValue_t returnCode) {
|
||||||
|
switch (actionId) {
|
||||||
|
case syrlinks::SET_TX_MODE_MODULATION: {
|
||||||
|
sif::warning << "CCSDSHandler::stepFailedReceived: Failed to set enable transmitter"
|
||||||
|
<< std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
sif::debug << "CCSDSHandler::stepFailedReceived: Received unexpected action reply"
|
||||||
|
<< std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCSDSHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCSDSHandler::completionSuccessfulReceived(ActionId_t actionId) {
|
||||||
|
switch (actionId) {
|
||||||
|
case syrlinks::SET_TX_MODE_MODULATION: {
|
||||||
|
triggerEvent(TRANSMITTER_ENABLED);
|
||||||
|
transmitterCountdown.setTimeout(transmitterTimeout);
|
||||||
|
linkState = UP;
|
||||||
|
// Set link state of all virtual channels to link up
|
||||||
|
forwardLinkstate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
sif::debug << "CCSDSHandler::completionSuccessfulReceived: Received unexpected action reply"
|
||||||
|
<< std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCSDSHandler::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
|
||||||
|
switch (actionId) {
|
||||||
|
case syrlinks::SET_TX_MODE_MODULATION: {
|
||||||
|
sif::warning << "CCSDSHandler::completionFailedReceived: Failed to set enable transmitter"
|
||||||
|
<< std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
sif::debug << "CCSDSHandler::completionFailedReceived: Received unexpected action reply"
|
||||||
|
<< std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CCSDSHandler::addVirtualChannel(VcId_t vcId, VirtualChannel* virtualChannel) {
|
void CCSDSHandler::addVirtualChannel(VcId_t vcId, VirtualChannel* virtualChannel) {
|
||||||
if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) {
|
if (vcId > common::NUMBER_OF_VIRTUAL_CHANNELS) {
|
||||||
sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl;
|
sif::warning << "CCSDSHandler::addVirtualChannel: Invalid virtual channel ID" << std::endl;
|
||||||
@ -312,14 +386,10 @@ void CCSDSHandler::enableTransmit() {
|
|||||||
// Transmitter already enabled
|
// Transmitter already enabled
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
transmitterCountdown.setTimeout(transmitterTimeout);
|
|
||||||
#ifndef TE0720_1CFA
|
#ifndef TE0720_1CFA
|
||||||
gpioIF->pullHigh(enTxClock);
|
gpioIF->pullHigh(enTxClock);
|
||||||
gpioIF->pullHigh(enTxData);
|
gpioIF->pullHigh(enTxData);
|
||||||
#endif /* BOARD_TE0720 == 0 */
|
#endif /* BOARD_TE0720 == 0 */
|
||||||
linkState = UP;
|
|
||||||
// Set link state of all virtual channels to link up
|
|
||||||
forwardLinkstate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSDSHandler::checkTxTimer() {
|
void CCSDSHandler::checkTxTimer() {
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
||||||
#include "fsfw_hal/common/gpio/GpioIF.h"
|
#include "fsfw_hal/common/gpio/GpioIF.h"
|
||||||
#include "fsfw_hal/common/gpio/gpioDefinitions.h"
|
#include "fsfw_hal/common/gpio/gpioDefinitions.h"
|
||||||
|
#include "fsfw/action/CommandActionHelper.h"
|
||||||
|
#include "fsfw/action/CommandsActionsIF.h"
|
||||||
#include "linux/obc/PtmeConfig.h"
|
#include "linux/obc/PtmeConfig.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +36,8 @@ class CCSDSHandler : public SystemObject,
|
|||||||
public AcceptsTelecommandsIF,
|
public AcceptsTelecommandsIF,
|
||||||
public HasReturnvaluesIF,
|
public HasReturnvaluesIF,
|
||||||
public ReceivesParameterMessagesIF,
|
public ReceivesParameterMessagesIF,
|
||||||
public HasActionsIF {
|
public HasActionsIF,
|
||||||
|
public CommandsActionsIF {
|
||||||
public:
|
public:
|
||||||
using VcId_t = uint8_t;
|
using VcId_t = uint8_t;
|
||||||
|
|
||||||
@ -79,8 +82,19 @@ class CCSDSHandler : public SystemObject,
|
|||||||
virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||||
const uint8_t* data, size_t size);
|
const uint8_t* data, size_t size);
|
||||||
|
|
||||||
|
MessageQueueIF* getCommandQueuePtr() override;
|
||||||
|
void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override;
|
||||||
|
void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override;
|
||||||
|
void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override;
|
||||||
|
void completionSuccessfulReceived(ActionId_t actionId) override;
|
||||||
|
void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER;
|
static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER;
|
||||||
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER;
|
||||||
|
|
||||||
|
//! [EXPORT] : [COMMENT] Syrlinks transmitter is enabled
|
||||||
|
static const Event TRANSMITTER_ENABLED = MAKE_EVENT(1, severity::LOW);
|
||||||
|
|
||||||
static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE;
|
static const uint32_t QUEUE_SIZE = common::CCSDS_HANDLER_QUEUE_SIZE;
|
||||||
|
|
||||||
@ -120,6 +134,7 @@ class CCSDSHandler : public SystemObject,
|
|||||||
|
|
||||||
MessageQueueIF* commandQueue = nullptr;
|
MessageQueueIF* commandQueue = nullptr;
|
||||||
MessageQueueIF* eventQueue = nullptr;
|
MessageQueueIF* eventQueue = nullptr;
|
||||||
|
MessageQueueIF* commandActionHelperQueue = nullptr;
|
||||||
|
|
||||||
ParameterHelper parameterHelper;
|
ParameterHelper parameterHelper;
|
||||||
|
|
||||||
@ -140,12 +155,15 @@ class CCSDSHandler : public SystemObject,
|
|||||||
// Countdown to disable transmitter after 15 minutes
|
// Countdown to disable transmitter after 15 minutes
|
||||||
Countdown transmitterCountdown;
|
Countdown transmitterCountdown;
|
||||||
|
|
||||||
|
CommandActionHelper commandActionHelper;
|
||||||
|
|
||||||
// When true transmitting is started as soon as carrier lock has been detected
|
// When true transmitting is started as soon as carrier lock has been detected
|
||||||
bool enableTxWhenCarrierLock = false;
|
bool enableTxWhenCarrierLock = false;
|
||||||
|
|
||||||
bool linkState = DOWN;
|
bool linkState = DOWN;
|
||||||
|
|
||||||
void readCommandQueue(void);
|
void readCommandQueue(void);
|
||||||
|
void readCommandActionHelperQueue(void);
|
||||||
void handleTelemetry();
|
void handleTelemetry();
|
||||||
void handleTelecommands();
|
void handleTelecommands();
|
||||||
void checkEvents();
|
void checkEvents();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
target_sources(${LIB_EIVE_MISSION} PRIVATE
|
target_sources(${LIB_EIVE_MISSION} PRIVATE
|
||||||
CCSDSHandler.cpp
|
CCSDSHandler.cpp
|
||||||
VirtualChannel.cpp
|
VirtualChannel.cpp
|
||||||
|
TmFunnel.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
target_sources(${LIB_EIVE_MISSION} PRIVATE
|
target_sources(${LIB_EIVE_MISSION} PRIVATE
|
||||||
TmFunnel.cpp
|
|
||||||
Timestamp.cpp
|
Timestamp.cpp
|
||||||
ProgressPrinter.cpp
|
ProgressPrinter.cpp
|
||||||
Filenaming.cpp
|
Filenaming.cpp
|
||||||
|
@ -1,114 +0,0 @@
|
|||||||
#include <fsfw/ipc/QueueFactory.h>
|
|
||||||
#include <fsfw/objectmanager/ObjectManager.h>
|
|
||||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
|
||||||
#include <fsfw/tmtcpacket/pus/tm.h>
|
|
||||||
#include <mission/utility/TmFunnel.h>
|
|
||||||
|
|
||||||
#include "OBSWConfig.h"
|
|
||||||
|
|
||||||
object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT;
|
|
||||||
object_id_t TmFunnel::storageDestination = objects::NO_OBJECT;
|
|
||||||
|
|
||||||
TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth, uint8_t reportReceptionVc)
|
|
||||||
: SystemObject(objectId), messageDepth(messageDepth), reportReceptionVc(reportReceptionVc) {
|
|
||||||
auto mqArgs = MqArgs(objectId, static_cast<void*>(this));
|
|
||||||
tmQueue = QueueFactory::instance()->createMessageQueue(
|
|
||||||
messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
|
|
||||||
storageQueue = QueueFactory::instance()->createMessageQueue(
|
|
||||||
messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
TmFunnel::~TmFunnel() {}
|
|
||||||
|
|
||||||
MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) {
|
|
||||||
return tmQueue->getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) {
|
|
||||||
TmTcMessage currentMessage;
|
|
||||||
ReturnValue_t status = tmQueue->receiveMessage(¤tMessage);
|
|
||||||
while (status == HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
status = handlePacket(¤tMessage);
|
|
||||||
if (status != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
status = tmQueue->receiveMessage(¤tMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == MessageQueueIF::EMPTY) {
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
} else {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) {
|
|
||||||
uint8_t* packetData = nullptr;
|
|
||||||
size_t size = 0;
|
|
||||||
ReturnValue_t result = tmStore->modifyData(message->getStorageId(), &packetData, &size);
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
TmPacketPusC packet(packetData);
|
|
||||||
packet.setPacketSequenceCount(this->sourceSequenceCount);
|
|
||||||
sourceSequenceCount++;
|
|
||||||
sourceSequenceCount = sourceSequenceCount % SpacePacketBase::LIMIT_SEQUENCE_COUNT;
|
|
||||||
packet.setErrorControl();
|
|
||||||
|
|
||||||
result = tmQueue->sendToDefault(message);
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
tmStore->deleteData(message->getStorageId());
|
|
||||||
sif::error << "TmFunnel::handlePacket: Error sending to downlink "
|
|
||||||
"handler"
|
|
||||||
<< std::endl;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (storageDestination != objects::NO_OBJECT) {
|
|
||||||
result = storageQueue->sendToDefault(message);
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
tmStore->deleteData(message->getStorageId());
|
|
||||||
sif::error << "TmFunnel::handlePacket: Error sending to storage "
|
|
||||||
"handler"
|
|
||||||
<< std::endl;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t TmFunnel::initialize() {
|
|
||||||
tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
|
|
||||||
if (tmStore == nullptr) {
|
|
||||||
sif::error << "TmFunnel::initialize: TM store not set." << std::endl;
|
|
||||||
sif::error << "Make sure the tm store is set up properly"
|
|
||||||
" and implements StorageManagerIF"
|
|
||||||
<< std::endl;
|
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
AcceptsTelemetryIF* tmTarget =
|
|
||||||
ObjectManager::instance()->get<AcceptsTelemetryIF>(downlinkDestination);
|
|
||||||
if (tmTarget == nullptr) {
|
|
||||||
sif::error << "TmFunnel::initialize: Downlink Destination not set." << std::endl;
|
|
||||||
sif::error << "Make sure the downlink destination object is set up "
|
|
||||||
"properly and implements AcceptsTelemetryIF"
|
|
||||||
<< std::endl;
|
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
tmQueue->setDefaultDestination(tmTarget->getReportReceptionQueue(reportReceptionVc));
|
|
||||||
|
|
||||||
// Storage destination is optional.
|
|
||||||
if (storageDestination == objects::NO_OBJECT) {
|
|
||||||
return SystemObject::initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
AcceptsTelemetryIF* storageTarget =
|
|
||||||
ObjectManager::instance()->get<AcceptsTelemetryIF>(storageDestination);
|
|
||||||
if (storageTarget != nullptr) {
|
|
||||||
storageQueue->setDefaultDestination(storageTarget->getReportReceptionQueue());
|
|
||||||
}
|
|
||||||
|
|
||||||
return SystemObject::initialize();
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
#ifndef MISSION_UTILITY_TMFUNNEL_H_
|
|
||||||
#define MISSION_UTILITY_TMFUNNEL_H_
|
|
||||||
|
|
||||||
#include <fsfw/ipc/MessageQueueIF.h>
|
|
||||||
#include <fsfw/objectmanager/SystemObject.h>
|
|
||||||
#include <fsfw/tasks/ExecutableObjectIF.h>
|
|
||||||
#include <fsfw/tmtcservices/AcceptsTelemetryIF.h>
|
|
||||||
#include <fsfw/tmtcservices/TmTcMessage.h>
|
|
||||||
|
|
||||||
namespace Factory {
|
|
||||||
void setStaticFrameworkObjectIds();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief TM Recipient.
|
|
||||||
* @details
|
|
||||||
* Main telemetry receiver. All generated telemetry is funneled into
|
|
||||||
* this object.
|
|
||||||
* @ingroup utility
|
|
||||||
* @author J. Meier
|
|
||||||
*/
|
|
||||||
class TmFunnel : public AcceptsTelemetryIF, public ExecutableObjectIF, public SystemObject {
|
|
||||||
friend void(Factory::setStaticFrameworkObjectIds)();
|
|
||||||
|
|
||||||
public:
|
|
||||||
TmFunnel(object_id_t objectId, uint32_t messageDepth = 20, uint8_t reportReceptionVc = 0);
|
|
||||||
virtual ~TmFunnel();
|
|
||||||
|
|
||||||
virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override;
|
|
||||||
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
|
||||||
virtual ReturnValue_t initialize() override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static object_id_t downlinkDestination;
|
|
||||||
static object_id_t storageDestination;
|
|
||||||
|
|
||||||
private:
|
|
||||||
uint32_t messageDepth = 0;
|
|
||||||
uint8_t reportReceptionVc = 0;
|
|
||||||
uint16_t sourceSequenceCount = 0;
|
|
||||||
MessageQueueIF* tmQueue = nullptr;
|
|
||||||
MessageQueueIF* storageQueue = nullptr;
|
|
||||||
|
|
||||||
StorageManagerIF* tmStore = nullptr;
|
|
||||||
|
|
||||||
ReturnValue_t handlePacket(TmTcMessage* message);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* MISSION_UTILITY_TMFUNNEL_H_ */
|
|
Loading…
Reference in New Issue
Block a user