on and normal mode finally work
Some checks failed
EIVE/eive-obsw/pipeline/pr-main There was a failure building this commit

This commit is contained in:
Robin Müller 2023-11-15 11:31:57 +01:00
parent 193c45ee33
commit bd74b95ffd
Signed by: muellerr
GPG Key ID: A649FB78196E3849
13 changed files with 152 additions and 2569 deletions

View File

@ -613,11 +613,11 @@ void ObjectFactory::createSyrlinksComponents(PowerSwitchIF* pwrSwitcher) {
#endif #endif
} }
void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF& pwrSwitch) { void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF& pwrSwitcher) {
using namespace gpio; using namespace gpio;
std::stringstream consumer; std::stringstream consumer;
auto* camSwitcher = auto* camSwitcher =
new CamSwitcher(objects::CAM_SWITCHER, pwrSwitch, power::PDU2_CH8_PAYLOAD_CAMERA); new CamSwitcher(objects::CAM_SWITCHER, pwrSwitcher, power::PDU2_CH8_PAYLOAD_CAMERA);
camSwitcher->connectModeTreeParent(satsystem::payload::SUBSYSTEM); camSwitcher->connectModeTreeParent(satsystem::payload::SUBSYSTEM);
#if OBSW_ADD_PLOC_MPSOC == 1 #if OBSW_ADD_PLOC_MPSOC == 1
consumer << "0x" << std::hex << objects::PLOC_MPSOC_HANDLER; consumer << "0x" << std::hex << objects::PLOC_MPSOC_HANDLER;
@ -651,18 +651,11 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit
new SerialCookie(objects::PLOC_SUPERVISOR_HANDLER, plocSupvDev, serial::PLOC_SUPV_BAUD, new SerialCookie(objects::PLOC_SUPERVISOR_HANDLER, plocSupvDev, serial::PLOC_SUPV_BAUD,
supv::MAX_PACKET_SIZE * 20, UartModes::NON_CANONICAL); supv::MAX_PACKET_SIZE * 20, UartModes::NON_CANONICAL);
supervisorCookie->setNoFixedSizeReply(); supervisorCookie->setNoFixedSizeReply();
auto supvHelper = new PlocSupvUartManager(objects::PLOC_SUPERVISOR_HELPER); new PlocSupvUartManager(objects::PLOC_SUPERVISOR_HELPER);
DhbConfig dhbConf(objects::PLOC_SUPERVISOR_HANDLER); DhbConfig dhbConf(objects::PLOC_SUPERVISOR_HANDLER);
auto* supvHandler = auto* supvHandler =
new FreshSupvHandler(dhbConf, supervisorCookie, Gpio(gpioIds::ENABLE_SUPV_UART, gpioComIF), new FreshSupvHandler(dhbConf, supervisorCookie, Gpio(gpioIds::ENABLE_SUPV_UART, gpioComIF),
pwrSwitch, power::PDU1_CH6_PLOC_12V, *supvHelper); pwrSwitcher, power::PDU1_CH6_PLOC_12V);
/*
auto* supvHandler = new PlocSupervisorHandler(objects::PLOC_SUPERVISOR_HANDLER, supervisorCookie,
Gpio(gpioIds::ENABLE_SUPV_UART, gpioComIF),
power::PDU1_CH6_PLOC_12V, *supvHelper);
supvHandler->setPowerSwitcher(&pwrSwitch);
*/
supvHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM); supvHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM);
#endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */ #endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */
static_cast<void>(consumer); static_cast<void>(consumer);

2
fsfw

@ -1 +1 @@
Subproject commit 91b194d8ebd79352ad358f955274d49f15dd3e6d Subproject commit 7673d8b396764186d93c3378496ccfc3c1b2e2e8

View File

@ -3,7 +3,6 @@ target_sources(
PUBLIC PlocMemoryDumper.cpp PUBLIC PlocMemoryDumper.cpp
PlocMpsocHandler.cpp PlocMpsocHandler.cpp
FreshSupvHandler.cpp FreshSupvHandler.cpp
PlocSupervisorHandler.cpp
PlocMpsocSpecialComHelper.cpp PlocMpsocSpecialComHelper.cpp
plocMpsocHelpers.cpp plocMpsocHelpers.cpp
PlocSupvUartMan.cpp PlocSupvUartMan.cpp

View File

@ -7,8 +7,10 @@
#include <filesystem> #include <filesystem>
#include "eive/definitions.h" #include "eive/definitions.h"
#include "eive/objects.h"
#include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/ipc/QueueFactory.h" #include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManagerIF.h"
#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/tasks/TaskFactory.h" #include "fsfw/tasks/TaskFactory.h"
#include "linux/payload/plocSupvDefs.h" #include "linux/payload/plocSupvDefs.h"
@ -19,10 +21,8 @@ using namespace returnvalue;
std::atomic_bool supv::SUPV_ON = false; std::atomic_bool supv::SUPV_ON = false;
FreshSupvHandler::FreshSupvHandler(DhbConfig cfg, CookieIF* comCookie, Gpio uartIsolatorSwitch, FreshSupvHandler::FreshSupvHandler(DhbConfig cfg, CookieIF* comCookie, Gpio uartIsolatorSwitch,
PowerSwitchIF& switchIF, power::Switch_t powerSwitch, PowerSwitchIF& switchIF, power::Switch_t powerSwitch)
PlocSupvUartManager& supvHelper)
: FreshDeviceHandlerBase(cfg), : FreshDeviceHandlerBase(cfg),
uartManager(supvHelper),
comCookie(comCookie), comCookie(comCookie),
switchIF(switchIF), switchIF(switchIF),
switchId(powerSwitch), switchId(powerSwitch),
@ -75,7 +75,8 @@ void FreshSupvHandler::performDeviceOperation(uint8_t opCode) {
buildActiveCmdKey(Apid::HK, static_cast<uint8_t>(tc::HkId::GET_REPORT))); buildActiveCmdKey(Apid::HK, static_cast<uint8_t>(tc::HkId::GET_REPORT)));
if (cmdIter == activeActionCmds.end() or not cmdIter->second.isPending) { if (cmdIter == activeActionCmds.end() or not cmdIter->second.isPending) {
spParams.buf = commandBuffer.data(); spParams.buf = commandBuffer.data();
sendEmptyCmd(Apid::HK, static_cast<uint8_t>(tc::HkId::GET_REPORT), true); sendEmptyCmd(supv::GET_HK_REPORT, Apid::HK, static_cast<uint8_t>(tc::HkId::GET_REPORT),
true);
} }
} }
} }
@ -195,7 +196,7 @@ ReturnValue_t FreshSupvHandler::executeAction(ActionId_t actionId, MessageQueueI
const uint8_t* data, size_t size) { const uint8_t* data, size_t size) {
using namespace supv; using namespace supv;
ReturnValue_t result; ReturnValue_t result;
if (uartManager.longerRequestActive()) { if (uartManager->longerRequestActive()) {
return result::SUPV_HELPER_EXECUTING; return result::SUPV_HELPER_EXECUTING;
} }
@ -209,14 +210,14 @@ ReturnValue_t FreshSupvHandler::executeAction(ActionId_t actionId, MessageQueueI
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
result = uartManager.performUpdate(params); result = uartManager->performUpdate(params);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
return EXECUTION_FINISHED; return EXECUTION_FINISHED;
} }
case CONTINUE_UPDATE: { case CONTINUE_UPDATE: {
uartManager.initiateUpdateContinuation(); uartManager->initiateUpdateContinuation();
return EXECUTION_FINISHED; return EXECUTION_FINISHED;
} }
case MEMORY_CHECK_WITH_FILE: { case MEMORY_CHECK_WITH_FILE: {
@ -228,7 +229,7 @@ ReturnValue_t FreshSupvHandler::executeAction(ActionId_t actionId, MessageQueueI
if (not std::filesystem::exists(params.file)) { if (not std::filesystem::exists(params.file)) {
return HasFileSystemIF::FILE_DOES_NOT_EXIST; return HasFileSystemIF::FILE_DOES_NOT_EXIST;
} }
uartManager.performMemCheck(params.file, params.memId, params.startAddr); uartManager->performMemCheck(params.file, params.memId, params.startAddr);
return EXECUTION_FINISHED; return EXECUTION_FINISHED;
} }
default: default:
@ -240,19 +241,21 @@ ReturnValue_t FreshSupvHandler::executeAction(ActionId_t actionId, MessageQueueI
spParams.buf = commandBuffer.data(); spParams.buf = commandBuffer.data();
switch (actionId) { switch (actionId) {
case GET_HK_REPORT: { case GET_HK_REPORT: {
sendEmptyCmd(Apid::HK, static_cast<uint8_t>(tc::HkId::GET_REPORT), true); sendEmptyCmd(supv::GET_HK_REPORT, Apid::HK, static_cast<uint8_t>(tc::HkId::GET_REPORT), true);
result = returnvalue::OK; result = returnvalue::OK;
break; break;
} }
case START_MPSOC: { case START_MPSOC: {
sif::info << "PLOC SUPV: Starting MPSoC" << std::endl; sif::info << "PLOC SUPV: Starting MPSoC" << std::endl;
sendEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::START_MPSOC), false); sendEmptyCmd(supv::START_MPSOC, Apid::BOOT_MAN,
static_cast<uint8_t>(tc::BootManId::START_MPSOC), false);
result = returnvalue::OK; result = returnvalue::OK;
break; break;
} }
case SHUTDOWN_MPSOC: { case SHUTDOWN_MPSOC: {
sif::info << "PLOC SUPV: Shutting down MPSoC" << std::endl; sif::info << "PLOC SUPV: Shutting down MPSoC" << std::endl;
sendEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SHUTDOWN_MPSOC), false); sendEmptyCmd(supv::SHUTDOWN_MPSOC, Apid::BOOT_MAN,
static_cast<uint8_t>(tc::BootManId::SHUTDOWN_MPSOC), false);
result = returnvalue::OK; result = returnvalue::OK;
break; break;
} }
@ -263,7 +266,8 @@ ReturnValue_t FreshSupvHandler::executeAction(ActionId_t actionId, MessageQueueI
} }
case RESET_MPSOC: { case RESET_MPSOC: {
sif::info << "PLOC SUPV: Resetting MPSoC" << std::endl; sif::info << "PLOC SUPV: Resetting MPSoC" << std::endl;
sendEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::RESET_MPSOC), false); sendEmptyCmd(supv::RESET_MPSOC, Apid::BOOT_MAN,
static_cast<uint8_t>(tc::BootManId::RESET_MPSOC), false);
result = returnvalue::OK; result = returnvalue::OK;
break; break;
} }
@ -287,8 +291,8 @@ ReturnValue_t FreshSupvHandler::executeAction(ActionId_t actionId, MessageQueueI
break; break;
} }
case GET_BOOT_STATUS_REPORT: { case GET_BOOT_STATUS_REPORT: {
sendEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::GET_BOOT_STATUS_REPORT), sendEmptyCmd(supv::GET_BOOT_STATUS_REPORT, Apid::BOOT_MAN,
true); static_cast<uint8_t>(tc::BootManId::GET_BOOT_STATUS_REPORT), true);
result = returnvalue::OK; result = returnvalue::OK;
break; break;
} }
@ -305,8 +309,8 @@ ReturnValue_t FreshSupvHandler::executeAction(ActionId_t actionId, MessageQueueI
break; break;
} }
case GET_LATCHUP_STATUS_REPORT: { case GET_LATCHUP_STATUS_REPORT: {
sendEmptyCmd(Apid::LATCHUP_MON, static_cast<uint8_t>(tc::LatchupMonId::GET_STATUS_REPORT), sendEmptyCmd(supv::GET_LATCHUP_STATUS_REPORT, Apid::LATCHUP_MON,
true); static_cast<uint8_t>(tc::LatchupMonId::GET_STATUS_REPORT), true);
result = returnvalue::OK; result = returnvalue::OK;
break; break;
} }
@ -328,12 +332,14 @@ ReturnValue_t FreshSupvHandler::executeAction(ActionId_t actionId, MessageQueueI
break; break;
} }
case FACTORY_FLASH: { case FACTORY_FLASH: {
sendEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::FACTORY_FLASH), false); sendEmptyCmd(supv::FACTORY_FLASH, Apid::BOOT_MAN,
static_cast<uint8_t>(tc::BootManId::FACTORY_FLASH), false);
result = returnvalue::OK; result = returnvalue::OK;
break; break;
} }
case RESET_PL: { case RESET_PL: {
sendEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::RESET_PL), false); sendEmptyCmd(supv::RESET_PL, Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::RESET_PL),
false);
result = returnvalue::OK; result = returnvalue::OK;
break; break;
} }
@ -357,12 +363,13 @@ ReturnValue_t FreshSupvHandler::executeAction(ActionId_t actionId, MessageQueueI
break; break;
} }
case REQUEST_ADC_REPORT: { case REQUEST_ADC_REPORT: {
sendEmptyCmd(Apid::ADC_MON, static_cast<uint8_t>(tc::AdcMonId::REQUEST_ADC_SAMPLE), true); sendEmptyCmd(supv::REQUEST_ADC_REPORT, Apid::ADC_MON,
static_cast<uint8_t>(tc::AdcMonId::REQUEST_ADC_SAMPLE), true);
result = returnvalue::OK; result = returnvalue::OK;
break; break;
} }
case REQUEST_LOGGING_COUNTERS: { case REQUEST_LOGGING_COUNTERS: {
sendEmptyCmd(Apid::DATA_LOGGER, sendEmptyCmd(supv::REQUEST_LOGGING_COUNTERS, Apid::DATA_LOGGER,
static_cast<uint8_t>(tc::DataLoggerServiceId::REQUEST_COUNTERS), true); static_cast<uint8_t>(tc::DataLoggerServiceId::REQUEST_COUNTERS), true);
result = returnvalue::OK; result = returnvalue::OK;
break; break;
@ -389,7 +396,7 @@ ReturnValue_t FreshSupvHandler::prepareSetTimeRefCmd() {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(supv::SET_TIME_REF, packet, false);
return returnvalue::OK; return returnvalue::OK;
} }
@ -424,12 +431,13 @@ ReturnValue_t FreshSupvHandler::prepareSelBootImageCmd(const uint8_t* commandDat
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(supv::SEL_MPSOC_BOOT_IMAGE, packet, false);
return returnvalue::OK; return returnvalue::OK;
} }
void FreshSupvHandler::startTransition(Mode_t newMode, Submode_t newSubmode) { void FreshSupvHandler::startTransition(Mode_t newMode, Submode_t newSubmode) {
if (newMode == mode or (mode == MODE_ON and newMode == MODE_NORMAL)) { if (newMode == mode or (mode == MODE_ON and newMode == MODE_NORMAL) or
(newMode == MODE_ON and mode == MODE_NORMAL)) {
// Can finish immediately. // Can finish immediately.
setMode(newMode, newSubmode); setMode(newMode, newSubmode);
return; return;
@ -469,7 +477,7 @@ void FreshSupvHandler::handleTransitionToOn() {
} }
if (startupState == StartupState::BOOTING and bootTimeout.hasTimedOut()) { if (startupState == StartupState::BOOTING and bootTimeout.hasTimedOut()) {
uartIsolatorSwitch.pullHigh(); uartIsolatorSwitch.pullHigh();
uartManager.start(); uartManager->start();
if (SET_TIME_DURING_BOOT) { if (SET_TIME_DURING_BOOT) {
startupState = StartupState::SET_TIME; startupState = StartupState::SET_TIME;
} else { } else {
@ -501,7 +509,7 @@ void FreshSupvHandler::handleTransitionToOff() {
if (shutdownState == ShutdownState::IDLE) { if (shutdownState == ShutdownState::IDLE) {
hkSet.setReportingEnabled(false); hkSet.setReportingEnabled(false);
hkSet.setValidity(false, true); hkSet.setValidity(false, true);
uartManager.stop(); uartManager->stop();
uartIsolatorSwitch.pullLow(); uartIsolatorSwitch.pullLow();
switchIF.sendSwitchCommand(switchId, PowerSwitchIF::SWITCH_OFF); switchIF.sendSwitchCommand(switchId, PowerSwitchIF::SWITCH_OFF);
shutdownState = ShutdownState::POWER_SWITCHING; shutdownState = ShutdownState::POWER_SWITCHING;
@ -515,13 +523,13 @@ void FreshSupvHandler::handleTransitionToOff() {
} }
} }
ReturnValue_t FreshSupvHandler::sendCommand(TcBase& tc, bool replyExpected, ReturnValue_t FreshSupvHandler::sendCommand(DeviceCommandId_t commandId, TcBase& tc,
uint32_t cmdCountdownMs) { bool replyExpected, uint32_t cmdCountdownMs) {
if (supv::DEBUG_PLOC_SUPV) { if (supv::DEBUG_PLOC_SUPV) {
sif::debug << "PLOC SUPV: SEND PACKET Size " << tc.getFullPacketLen() << " Module APID " sif::debug << "PLOC SUPV: SEND PACKET Size " << tc.getFullPacketLen() << " Module APID "
<< (int)tc.getModuleApid() << " Service ID " << (int)tc.getServiceId() << std::endl; << (int)tc.getModuleApid() << " Service ID " << (int)tc.getServiceId() << std::endl;
} }
ActiveCmdInfo info(cmdCountdownMs); ActiveCmdInfo info(commandId, cmdCountdownMs);
auto activeCmdIter = auto activeCmdIter =
activeActionCmds.find(buildActiveCmdKey(tc.getModuleApid(), tc.getServiceId())); activeActionCmds.find(buildActiveCmdKey(tc.getModuleApid(), tc.getServiceId()));
if (activeCmdIter == activeActionCmds.end()) { if (activeCmdIter == activeActionCmds.end()) {
@ -532,6 +540,7 @@ ReturnValue_t FreshSupvHandler::sendCommand(TcBase& tc, bool replyExpected,
return HasActionsIF::IS_BUSY; return HasActionsIF::IS_BUSY;
} }
activeCmdIter->second.isPending = true; activeCmdIter->second.isPending = true;
activeCmdIter->second.commandId = commandId;
activeCmdIter->second.ackRecv = false; activeCmdIter->second.ackRecv = false;
activeCmdIter->second.ackExeRecv = false; activeCmdIter->second.ackExeRecv = false;
activeCmdIter->second.replyPacketExpected = replyExpected; activeCmdIter->second.replyPacketExpected = replyExpected;
@ -539,11 +548,16 @@ ReturnValue_t FreshSupvHandler::sendCommand(TcBase& tc, bool replyExpected,
activeCmdIter->second.cmdCountdown.setTimeout(cmdCountdownMs); activeCmdIter->second.cmdCountdown.setTimeout(cmdCountdownMs);
activeCmdIter->second.cmdCountdown.resetTimer(); activeCmdIter->second.cmdCountdown.resetTimer();
} }
return uartManager.sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen()); return uartManager->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen());
} }
ReturnValue_t FreshSupvHandler::initialize() { ReturnValue_t FreshSupvHandler::initialize() {
uartManager.initializeInterface(comCookie); uartManager =
ObjectManager::instance()->get<PlocSupvUartManager>(objects::PLOC_SUPERVISOR_HELPER);
if (uartManager == nullptr) {
return returnvalue::FAILED;
}
uartManager->initializeInterface(comCookie);
ReturnValue_t result = eventSubscription(); ReturnValue_t result = eventSubscription();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -552,13 +566,14 @@ ReturnValue_t FreshSupvHandler::initialize() {
return FreshDeviceHandlerBase::initialize(); return FreshDeviceHandlerBase::initialize();
} }
ReturnValue_t FreshSupvHandler::sendEmptyCmd(uint16_t apid, uint8_t serviceId, bool replyExpected) { ReturnValue_t FreshSupvHandler::sendEmptyCmd(DeviceCommandId_t commandId, uint16_t apid,
uint8_t serviceId, bool replyExpected) {
supv::NoPayloadPacket packet(spParams, apid, serviceId); supv::NoPayloadPacket packet(spParams, apid, serviceId);
ReturnValue_t result = packet.buildPacket(); ReturnValue_t result = packet.buildPacket();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, replyExpected); sendCommand(commandId, packet, replyExpected);
return returnvalue::OK; return returnvalue::OK;
} }
@ -574,7 +589,7 @@ ReturnValue_t FreshSupvHandler::prepareSetBootTimeoutCmd(const uint8_t* commandD
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(supv::SET_BOOT_TIMEOUT, packet, false);
return returnvalue::OK; return returnvalue::OK;
} }
@ -589,7 +604,7 @@ ReturnValue_t FreshSupvHandler::prepareRestartTriesCmd(const uint8_t* commandDat
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(supv::ENABLE_AUTO_TM, packet, false);
return returnvalue::OK; return returnvalue::OK;
} }
@ -599,7 +614,7 @@ ReturnValue_t FreshSupvHandler::prepareDisableHk() {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(supv::DISABLE_AUTO_TM, packet, false);
return returnvalue::OK; return returnvalue::OK;
} }
@ -621,7 +636,7 @@ ReturnValue_t FreshSupvHandler::prepareLatchupConfigCmd(const uint8_t* commandDa
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(deviceCommand, packet, false);
break; break;
} }
case (supv::DISABLE_LATCHUP_ALERT): { case (supv::DISABLE_LATCHUP_ALERT): {
@ -630,7 +645,7 @@ ReturnValue_t FreshSupvHandler::prepareLatchupConfigCmd(const uint8_t* commandDa
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(deviceCommand, packet, false);
break; break;
} }
default: { default: {
@ -661,7 +676,7 @@ ReturnValue_t FreshSupvHandler::prepareSetAlertLimitCmd(const uint8_t* commandDa
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(supv::SET_ALERT_LIMIT, packet, false);
return returnvalue::OK; return returnvalue::OK;
} }
@ -686,7 +701,7 @@ ReturnValue_t FreshSupvHandler::prepareSetShutdownTimeoutCmd(const uint8_t* comm
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(supv::SET_SHUTDOWN_TIMEOUT, packet, false);
return returnvalue::OK; return returnvalue::OK;
} }
@ -703,7 +718,7 @@ ReturnValue_t FreshSupvHandler::prepareSetGpioCmd(const uint8_t* commandData,
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(supv::SET_GPIO, packet, false);
return returnvalue::OK; return returnvalue::OK;
} }
@ -719,7 +734,7 @@ ReturnValue_t FreshSupvHandler::prepareReadGpioCmd(const uint8_t* commandData,
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(supv::READ_GPIO, packet, false);
return returnvalue::OK; return returnvalue::OK;
} }
@ -732,7 +747,7 @@ ReturnValue_t FreshSupvHandler::prepareFactoryResetCmd(const uint8_t* commandDat
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(resetCmd, false); sendCommand(supv::FACTORY_RESET, resetCmd, false);
return returnvalue::OK; return returnvalue::OK;
} }
@ -743,7 +758,7 @@ ReturnValue_t FreshSupvHandler::prepareSetAdcEnabledChannelsCmd(const uint8_t* c
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(supv::SET_ADC_ENABLED_CHANNELS, packet, false);
return returnvalue::OK; return returnvalue::OK;
} }
@ -757,7 +772,7 @@ ReturnValue_t FreshSupvHandler::prepareSetAdcWindowAndStrideCmd(const uint8_t* c
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(supv::SET_ADC_WINDOW_AND_STRIDE, packet, false);
return returnvalue::OK; return returnvalue::OK;
} }
@ -769,7 +784,7 @@ ReturnValue_t FreshSupvHandler::prepareSetAdcThresholdCmd(const uint8_t* command
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(supv::SET_ADC_THRESHOLD, packet, false);
return returnvalue::OK; return returnvalue::OK;
} }
@ -790,7 +805,7 @@ ReturnValue_t FreshSupvHandler::prepareWipeMramCmd(const uint8_t* commandData, s
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sendCommand(packet, false); sendCommand(supv::WIPE_MRAM, packet, false);
return returnvalue::OK; return returnvalue::OK;
} }
@ -798,11 +813,16 @@ ReturnValue_t FreshSupvHandler::parseTmPackets() {
uint8_t* receivedData = nullptr; uint8_t* receivedData = nullptr;
size_t receivedSize = 0; size_t receivedSize = 0;
while (true) { while (true) {
ReturnValue_t result = uartManager.readReceivedMessage(comCookie, &receivedData, &receivedSize); ReturnValue_t result =
uartManager->readReceivedMessage(comCookie, &receivedData, &receivedSize);
if (result != returnvalue::OK or receivedSize == 0) { if (result != returnvalue::OK or receivedSize == 0) {
break; break;
} }
tmReader.setData(receivedData, receivedSize); tmReader.setReadOnlyData(receivedData, receivedSize);
if (tmReader.checkCrc() != returnvalue::OK) {
sif::warning << "PlocSupervisorHandler::parseTmPackets: CRC failure" << std::endl;
continue;
}
uint16_t apid = tmReader.getModuleApid(); uint16_t apid = tmReader.getModuleApid();
if (supv::DEBUG_PLOC_SUPV) { if (supv::DEBUG_PLOC_SUPV) {
handlePacketPrint(); handlePacketPrint();
@ -892,9 +912,17 @@ void FreshSupvHandler::handlePacketPrint() {
if ((tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::ACK)) or if ((tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::ACK)) or
(tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::NAK))) { (tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::NAK))) {
AcknowledgmentReport ack(tmReader); AcknowledgmentReport ack(tmReader);
ReturnValue_t result = ack.parse(); ReturnValue_t result = ack.parse(false);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::warning << "PlocSupervisorHandler: Parsing ACK failed" << std::endl; sif::warning << "PlocSupervisorHandler: Parsing ACK failed. ";
if (result == result::INVALID_SERVICE_ID) {
sif::warning << "Invalid service ID" << std::endl;
} else if (result == result::CRC_FAILURE) {
sif::warning << "CRC check failed" << std::endl;
} else {
sif::warning << "Returncode 0x" << std::hex << std::setw(4) << result << std::dec
<< std::endl;
}
} }
if (supv::REDUCE_NORMAL_MODE_PRINTOUT and if (supv::REDUCE_NORMAL_MODE_PRINTOUT and
ack.getRefModuleApid() == (uint8_t)supv::Apid::HK and ack.getRefModuleApid() == (uint8_t)supv::Apid::HK and
@ -915,7 +943,7 @@ void FreshSupvHandler::handlePacketPrint() {
} else if ((tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK)) or } else if ((tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK)) or
(tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_NAK))) { (tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_NAK))) {
ExecutionReport exe(tmReader); ExecutionReport exe(tmReader);
ReturnValue_t result = exe.parse(); ReturnValue_t result = exe.parse(false);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::warning << "PlocSupervisorHandler: Parsing EXE failed" << std::endl; sif::warning << "PlocSupervisorHandler: Parsing EXE failed" << std::endl;
} }
@ -1092,13 +1120,8 @@ ReturnValue_t FreshSupvHandler::eventSubscription() {
ReturnValue_t FreshSupvHandler::handleAckReport(const uint8_t* data) { ReturnValue_t FreshSupvHandler::handleAckReport(const uint8_t* data) {
using namespace supv; using namespace supv;
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
if (not tmReader.verifyCrc()) {
sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl;
triggerEvent(SUPV_CRC_FAILURE_EVENT);
return returnvalue::FAILED;
}
AcknowledgmentReport ack(tmReader); AcknowledgmentReport ack(tmReader);
result = ack.parse(); result = ack.parse(false);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
@ -1111,7 +1134,7 @@ ReturnValue_t FreshSupvHandler::handleAckReport(const uint8_t* data) {
ActiveCmdInfo& info = infoIter->second; ActiveCmdInfo& info = infoIter->second;
if (tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::NAK)) { if (tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::TmtcId::NAK)) {
triggerEvent(SUPV_ACK_FAILURE, info.commandId, static_cast<uint32_t>(ack.getStatusCode())); triggerEvent(SUPV_ACK_FAILURE, info.commandId, static_cast<uint32_t>(ack.getStatusCode()));
ack.printStatusInformation(); ack.printStatusInformationAck();
printAckFailureInfo(ack.getStatusCode(), info.commandId); printAckFailureInfo(ack.getStatusCode(), info.commandId);
if (info.commandedBy != MessageQueueIF::NO_QUEUE) { if (info.commandedBy != MessageQueueIF::NO_QUEUE) {
actionHelper.finish(false, info.commandedBy, info.commandId, result::RECEIVED_ACK_FAILURE); actionHelper.finish(false, info.commandedBy, info.commandId, result::RECEIVED_ACK_FAILURE);
@ -1129,7 +1152,9 @@ void FreshSupvHandler::performCommandCompletionHandling(supv::Apid apid, uint8_t
ActiveCmdInfo& info) { ActiveCmdInfo& info) {
if (info.ackRecv and info.ackExeRecv and if (info.ackRecv and info.ackExeRecv and
(not info.replyPacketExpected or info.replyPacketReceived)) { (not info.replyPacketExpected or info.replyPacketReceived)) {
actionHelper.finish(true, info.commandedBy, info.commandId, returnvalue::OK); if (info.commandedBy != MessageQueueIF::NO_QUEUE) {
actionHelper.finish(true, info.commandedBy, info.commandId, returnvalue::OK);
}
info.isPending = false; info.isPending = false;
} }
} }
@ -1154,13 +1179,10 @@ uint32_t FreshSupvHandler::buildActiveCmdKey(uint16_t moduleApid, uint8_t servic
ReturnValue_t FreshSupvHandler::handleExecutionReport(const uint8_t* data) { ReturnValue_t FreshSupvHandler::handleExecutionReport(const uint8_t* data) {
using namespace supv; using namespace supv;
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
if (not tmReader.verifyCrc()) {
return result::CRC_FAILURE;
}
ExecutionReport exe(tmReader); ExecutionReport exe(tmReader);
result = exe.parse(); result = exe.parse(false);
if (result != OK) { if (result != OK) {
sif::warning << "FreshSupvHandler::handleExecutionReport: Parsing ACK EXE failed" << std::endl;
return result; return result;
} }
auto infoIter = auto infoIter =
@ -1219,7 +1241,7 @@ ReturnValue_t FreshSupvHandler::handleExecutionSuccessReport(ActiveCmdInfo& info
void FreshSupvHandler::handleExecutionFailureReport(ActiveCmdInfo& info, ExecutionReport& report) { void FreshSupvHandler::handleExecutionFailureReport(ActiveCmdInfo& info, ExecutionReport& report) {
using namespace supv; using namespace supv;
report.printStatusInformation(); report.printStatusInformationExe();
if (info.commandId != DeviceHandlerIF::NO_COMMAND_ID) { if (info.commandId != DeviceHandlerIF::NO_COMMAND_ID) {
triggerEvent(SUPV_EXE_FAILURE, info.commandId, static_cast<uint32_t>(report.getStatusCode())); triggerEvent(SUPV_EXE_FAILURE, info.commandId, static_cast<uint32_t>(report.getStatusCode()));
} }

View File

@ -22,8 +22,7 @@ class FreshSupvHandler : public FreshDeviceHandlerBase {
enum OpCode { DEFAULT_OPERATION = 0, PARSE_TM = 1 }; enum OpCode { DEFAULT_OPERATION = 0, PARSE_TM = 1 };
FreshSupvHandler(DhbConfig cfg, CookieIF* comCookie, Gpio uartIsolatorSwitch, FreshSupvHandler(DhbConfig cfg, CookieIF* comCookie, Gpio uartIsolatorSwitch,
PowerSwitchIF& switchIF, power::Switch_t powerSwitch, PowerSwitchIF& switchIF, power::Switch_t powerSwitch);
PlocSupvUartManager& supvHelper);
/** /**
* Periodic helper executed function, implemented by child class. * Periodic helper executed function, implemented by child class.
*/ */
@ -82,7 +81,7 @@ class FreshSupvHandler : public FreshDeviceHandlerBase {
enum class ShutdownState : uint8_t { IDLE, POWER_SWITCHING }; enum class ShutdownState : uint8_t { IDLE, POWER_SWITCHING };
ShutdownState shutdownState = ShutdownState::IDLE; ShutdownState shutdownState = ShutdownState::IDLE;
PlocSupvUartManager uartManager; PlocSupvUartManager* uartManager;
CookieIF* comCookie; CookieIF* comCookie;
PowerSwitchIF& switchIF; PowerSwitchIF& switchIF;
power::Switch_t switchId; power::Switch_t switchId;
@ -114,7 +113,8 @@ class FreshSupvHandler : public FreshDeviceHandlerBase {
pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER);
struct ActiveCmdInfo { struct ActiveCmdInfo {
ActiveCmdInfo(uint32_t cmdCountdownMs) : cmdCountdown(cmdCountdownMs) {} ActiveCmdInfo(DeviceCommandId_t commandId, uint32_t cmdCountdownMs)
: commandId(commandId), cmdCountdown(cmdCountdownMs) {}
DeviceCommandId_t commandId = DeviceHandlerIF::NO_COMMAND_ID; DeviceCommandId_t commandId = DeviceHandlerIF::NO_COMMAND_ID;
bool isPending = false; bool isPending = false;
@ -132,14 +132,16 @@ class FreshSupvHandler : public FreshDeviceHandlerBase {
// Map for Action commands. For normal commands, a separate static structure will be used. // Map for Action commands. For normal commands, a separate static structure will be used.
std::map<uint32_t, ActiveCmdInfo> activeActionCmds; std::map<uint32_t, ActiveCmdInfo> activeActionCmds;
std::array<uint8_t, supv::MAX_COMMAND_SIZE> commandBuffer; std::array<uint8_t, supv::MAX_COMMAND_SIZE> commandBuffer{};
SpacePacketCreator creator; SpacePacketCreator creator;
supv::TcParams spParams = supv::TcParams(creator); supv::TcParams spParams = supv::TcParams(creator);
ReturnValue_t parseTmPackets(); ReturnValue_t parseTmPackets();
ReturnValue_t sendCommand(TcBase& tc, bool replyPacketExpected, uint32_t cmdCountdownMs = 1000); ReturnValue_t sendCommand(DeviceCommandId_t commandId, TcBase& tc, bool replyPacketExpected,
ReturnValue_t sendEmptyCmd(uint16_t apid, uint8_t serviceId, bool replyPacketExpected); uint32_t cmdCountdownMs = 1000);
ReturnValue_t sendEmptyCmd(DeviceCommandId_t commandId, uint16_t apid, uint8_t serviceId,
bool replyPacketExpected);
ReturnValue_t prepareSelBootImageCmd(const uint8_t* commandData); ReturnValue_t prepareSelBootImageCmd(const uint8_t* commandData);
ReturnValue_t prepareSetTimeRefCmd(); ReturnValue_t prepareSetTimeRefCmd();
ReturnValue_t prepareSetBootTimeoutCmd(const uint8_t* commandData, size_t cmdDataLen); ReturnValue_t prepareSetBootTimeoutCmd(const uint8_t* commandData, size_t cmdDataLen);

View File

@ -21,8 +21,7 @@ PlocMpsocHandler::PlocMpsocHandler(object_id_t objectId, object_id_t uartComIFid
sif::error << "PlocMPSoCHandler: Invalid communication cookie" << std::endl; sif::error << "PlocMPSoCHandler: Invalid communication cookie" << std::endl;
} }
eventQueue = QueueFactory::instance()->createMessageQueue(10); eventQueue = QueueFactory::instance()->createMessageQueue(10);
commandActionHelperQueue = commandActionHelperQueue = QueueFactory::instance()->createMessageQueue(10);
QueueFactory::instance()->createMessageQueue(10);
spParams.maxSize = sizeof(commandBuffer); spParams.maxSize = sizeof(commandBuffer);
spParams.buf = commandBuffer; spParams.buf = commandBuffer;
} }

View File

@ -504,7 +504,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::checkReceivedTm() {
triggerEvent(MPSOC_TM_SIZE_ERROR); triggerEvent(MPSOC_TM_SIZE_ERROR);
return result; return result;
} }
spReader.checkCrc(); result = spReader.checkCrc();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::warning << "PLOC MPSoC: CRC check failed" << std::endl; sif::warning << "PLOC MPSoC: CRC check failed" << std::endl;
triggerEvent(MPSOC_TM_CRC_MISSMATCH, *sequenceCount); triggerEvent(MPSOC_TM_CRC_MISSMATCH, *sequenceCount);

File diff suppressed because it is too large Load Diff

View File

@ -1,386 +0,0 @@
#ifndef MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_
#define MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_
#include <linux/payload/PlocSupvUartMan.h>
#include <linux/payload/plocSupvDefs.h>
#include <mission/controller/controllerdefinitions/PowerCtrlDefinitions.h>
#include "OBSWConfig.h"
#include "devices/powerSwitcherList.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "fsfw/timemanager/Countdown.h"
#include "fsfw_hal/linux/gpio/Gpio.h"
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h"
#include "fsfw_hal/linux/serial/SerialComIF.h"
#ifdef XIPHOS_Q7S
#include "bsp_q7s/fs/SdCardManager.h"
#endif
using supv::ExecutionReport;
using supv::TcBase;
/**
* @brief This is the device handler for the supervisor of the PLOC which is programmed by
* Thales.
*
* @details The PLOC uses the space packet protocol for communication. On each command the PLOC
* answers with at least one acknowledgment and one execution report.
* Flight manual:
* https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/PLOC_Commands
* ILH ICD: https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/
* Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960
* @author J. Meier
*/
class PlocSupervisorHandler : public DeviceHandlerBase {
public:
PlocSupervisorHandler(object_id_t objectId, CookieIF* comCookie, Gpio uartIsolatorSwitch,
power::Switch_t powerSwitch, PlocSupvUartManager& supvHelper);
virtual ~PlocSupervisorHandler();
virtual ReturnValue_t initialize() override;
void performOperationHook() override;
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override;
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
size_t* foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command,
uint8_t expectedReplies = 1, bool useAlternateId = false,
DeviceCommandId_t alternateReplyID = 0) override;
size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
// ReturnValue_t doSendReadHook() override;
void doOffActivity() override;
private:
static const uint16_t APID_MASK = 0x7FF;
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
static const uint8_t EXE_STATUS_OFFSET = 10;
static const uint8_t SIZE_NULL_TERMINATOR = 1;
// 5 s
static const uint32_t EXECUTION_DEFAULT_TIMEOUT = 5000;
// 70 S
static const uint32_t ACKNOWLEDGE_DEFAULT_TIMEOUT = 5000;
// 60 s
static const uint32_t MRAM_DUMP_EXECUTION_TIMEOUT = 60000;
// 70 s
static const uint32_t COPY_ADC_TO_MRAM_TIMEOUT = 70000;
// 60 s
static const uint32_t MRAM_DUMP_TIMEOUT = 60000;
enum class StartupState : uint8_t {
OFF,
BOOTING,
SET_TIME,
WAIT_FOR_TIME_REPLY,
TIME_WAS_SET,
ON
};
static constexpr bool SET_TIME_DURING_BOOT = true;
StartupState startupState = StartupState::OFF;
uint8_t commandBuffer[supv::MAX_COMMAND_SIZE];
SpacePacketCreator creator;
supv::TcParams spParams = supv::TcParams(creator);
/**
* This variable is used to store the id of the next reply to receive. This is necessary
* because the PLOC sends as reply to each command at least one acknowledgment and execution
* report.
*/
DeviceCommandId_t nextReplyId = supv::NONE;
SerialComIF* uartComIf = nullptr;
LinuxLibgpioIF* gpioComIF = nullptr;
Gpio uartIsolatorSwitch;
bool shutdownCmdSent = false;
// Yeah, I am using an extra variable because I once again don't know
// what the hell the base class is doing and I don't care anymore.
bool normalCommandIsPending = false;
// True men implement their reply timeout handling themselves!
Countdown normalCmdCd = Countdown(2000);
bool commandIsPending = false;
Countdown cmdCd = Countdown(2000);
supv::HkSet hkset;
supv::BootStatusReport bootStatusReport;
supv::LatchupStatusReport latchupStatusReport;
supv::CountersReport countersReport;
supv::AdcReport adcReport;
const power::Switch_t powerSwitch = power::NO_SWITCH;
supv::TmBase tmReader;
PlocSupvUartManager& uartManager;
MessageQueueIF* eventQueue = nullptr;
/** Number of expected replies following the MRAM dump command */
uint32_t expectedMramDumpPackets = 0;
uint32_t receivedMramDumpPackets = 0;
/** Set to true as soon as a complete space packet is present in the spacePacketBuffer */
bool packetInBuffer = false;
/** This buffer is used to concatenate space packets received in two different read steps */
uint8_t spacePacketBuffer[supv::MAX_PACKET_SIZE];
#ifdef XIPHOS_Q7S
SdCardManager* sdcMan = nullptr;
#endif
// Path to supervisor specific files on SD card
std::string supervisorFilePath = "ploc/supervisor";
std::string activeMramFile;
Countdown executionReportTimeout = Countdown(EXECUTION_DEFAULT_TIMEOUT, false);
Countdown acknowledgementReportTimeout = Countdown(ACKNOWLEDGE_DEFAULT_TIMEOUT, false);
// Vorago nees some time to boot properly
Countdown bootTimeout = Countdown(supv::BOOT_TIMEOUT_MS);
Countdown mramDumpTimeout = Countdown(MRAM_DUMP_TIMEOUT);
PoolEntry<uint16_t> adcRawEntry = PoolEntry<uint16_t>(16);
PoolEntry<uint16_t> adcEngEntry = PoolEntry<uint16_t>(16);
PoolEntry<uint32_t> latchupCounters = PoolEntry<uint32_t>(7);
PoolEntry<uint8_t> fmcStateEntry = PoolEntry<uint8_t>(1);
PoolEntry<uint8_t> bootStateEntry = PoolEntry<uint8_t>(1);
PoolEntry<uint8_t> bootCyclesEntry = PoolEntry<uint8_t>(1);
PoolEntry<uint32_t> tempSupEntry = PoolEntry<uint32_t>(1);
/**
* @brief Adjusts the timeout of the execution report dependent on command
*/
void setExecutionTimeout(DeviceCommandId_t command);
void handlePacketPrint();
/**
* @brief Handles event messages received from the supervisor helper
*/
void handleEvent(EventMessage* eventMessage);
ReturnValue_t getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches);
/**
* @brief This function checks the crc of the received PLOC reply.
*
* @param start Pointer to the first byte of the reply.
* @param foundLen Pointer to the length of the whole packet.
*
* @return returnvalue::OK if CRC is ok, otherwise CRC_FAILURE.
*/
ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen);
/**
* @brief This function handles the acknowledgment report.
*
* @param data Pointer to the data holding the acknowledgment report.
*
* @return returnvalue::OK if successful, otherwise an error code.
*/
ReturnValue_t handleAckReport(const uint8_t* data);
/**
* @brief This function handles the data of a execution report.
*
* @param data Pointer to the received data packet.
*
* @return returnvalue::OK if successful, otherwise an error code.
*/
ReturnValue_t handleExecutionReport(const uint8_t* data);
/**
* @brief This function handles the housekeeping report. This means verifying the CRC of the
* reply and filling the appropriate dataset.
*
* @param data Pointer to the data buffer holding the housekeeping read report.
*
* @return returnvalue::OK if successful, otherwise an error code.
*/
ReturnValue_t handleHkReport(const uint8_t* data);
/**
* @brief This function calls the function to check the CRC of the received boot status report
* and fills the associated dataset with the boot status information.
*/
ReturnValue_t handleBootStatusReport(const uint8_t* data);
ReturnValue_t handleLatchupStatusReport(const uint8_t* data);
ReturnValue_t handleCounterReport(const uint8_t* data);
void handleBadApidServiceCombination(Event result, unsigned int apid, unsigned int serviceId);
ReturnValue_t handleAdcReport(const uint8_t* data);
ReturnValue_t genericHandleTm(const char* contextString, const uint8_t* data,
LocalPoolDataSetBase& set);
void disableCommand(DeviceCommandId_t cmd);
/**
* @brief Depending on the current active command, this function sets the reply id of the
* next reply after a successful acknowledgment report has been received. This is
* required by the function getNextReplyLength() to identify the length of the next
* reply to read.
*/
void setNextReplyId();
/**
* @brief This function handles action message replies in case the telemetry has been
* requested by another object.
*
* @param data Pointer to the telemetry data.
* @param dataSize Size of telemetry in bytes.
* @param replyId Id of the reply. This will be added to the ActionMessage.
*/
void handleDeviceTm(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId);
/**
* @brief This function prepares a space packet which does not transport any data in the
* packet data field apart from the crc.
*/
ReturnValue_t prepareEmptyCmd(uint16_t apid, uint8_t serviceId);
/**
* @brief This function initializes the space packet to select the boot image of the MPSoC.
*/
ReturnValue_t prepareSelBootImageCmd(const uint8_t* commandData);
ReturnValue_t prepareDisableHk();
/**
* @brief This function fills the commandBuffer with the data to update the time of the
* PLOC supervisor.
*/
ReturnValue_t prepareSetTimeRefCmd();
/**
* @brief This function fills the commandBuffer with the data to change the boot timeout
* value in the PLOC supervisor.
*/
ReturnValue_t prepareSetBootTimeoutCmd(const uint8_t* commandData);
ReturnValue_t prepareRestartTriesCmd(const uint8_t* commandData);
ReturnValue_t prepareFactoryResetCmd(const uint8_t* commandData, size_t len);
/**
* @brief This function fills the command buffer with the packet to enable or disable the
* watchdogs on the PLOC.
*/
void prepareWatchdogsEnableCmd(const uint8_t* commandData);
/**
* @brief This function fills the command buffer with the packet to set the watchdog timer
* of one of the three watchdogs (PS, PL, INT).
*/
ReturnValue_t prepareWatchdogsConfigTimeoutCmd(const uint8_t* commandData);
ReturnValue_t prepareLatchupConfigCmd(const uint8_t* commandData,
DeviceCommandId_t deviceCommand);
ReturnValue_t prepareSetAlertLimitCmd(const uint8_t* commandData);
ReturnValue_t prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData);
ReturnValue_t prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData);
ReturnValue_t prepareSetAdcThresholdCmd(const uint8_t* commandData);
ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData);
ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData);
ReturnValue_t prepareSetGpioCmd(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareReadGpioCmd(const uint8_t* commandData, size_t commandDataLen);
/**
* @brief Copies the content of a space packet to the command buffer.
*/
void finishTcPrep(TcBase& tc);
/**
* @brief In case an acknowledgment failure reply has been received this function disables
* all previously enabled commands and resets the exepected replies variable of an
* active command.
*/
void disableAllReplies();
void disableReply(DeviceCommandId_t replyId);
/**
* @brief This function sends a failure report if the active action was commanded by an other
* object.
*
* @param replyId The id of the reply which signals a failure.
* @param status A status byte which gives information about the failure type.
*/
void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status);
/**
* @brief This function disables the execution report reply. Within this function also the
* the variable expectedReplies of an active command will be set to 0.
*/
void disableExeReportReply();
/**
* @brief This function generates the Service 8 packets for the MRAM dump data.
*/
ReturnValue_t handleMramDumpPacket(DeviceCommandId_t id);
/**
* @brief With this function the number of expected replies following an MRAM dump command
* will be increased. This is necessary to release the command in case not all replies
* have been received.
*/
void increaseExpectedMramReplies(DeviceCommandId_t id);
/**
* @brief Writes the data of the MRAM dump to a file. The file will be created when receiving
* the first packet.
*/
ReturnValue_t handleMramDumpFile(DeviceCommandId_t id);
/**
* @brief Extracts the length field of a spacePacket referenced by the spacePacket pointer.
*
* @param spacePacket Pointer to the buffer holding the space packet.
*
* @return The value stored in the length field of the data field.
*/
uint16_t readSpacePacketLength(uint8_t* spacePacket);
/**
* @brief Extracts the sequence flags from a space packet referenced by the spacePacket
* pointer.
*
* @param spacePacket Pointer to the buffer holding the space packet.
*
* @return uint8_t where the two least significant bits hold the sequence flags.
*/
uint8_t readSequenceFlags(uint8_t* spacePacket);
ReturnValue_t createMramDumpFile();
ReturnValue_t getTimeStampString(std::string& timeStamp);
ReturnValue_t prepareSetShutdownTimeoutCmd(const uint8_t* commandData);
ReturnValue_t extractUpdateCommand(const uint8_t* commandData, size_t size,
supv::UpdateParams& params);
ReturnValue_t extractBaseParams(const uint8_t** commandData, size_t& remSize,
supv::UpdateParams& params);
ReturnValue_t eventSubscription();
ReturnValue_t handleExecutionSuccessReport(ExecutionReport& report);
void handleExecutionFailureReport(ExecutionReport& report);
void printAckFailureInfo(uint16_t statusCode, DeviceCommandId_t commandId);
pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER);
ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode,
uint32_t* msToReachTheMode) override;
};
#endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */

View File

@ -80,7 +80,6 @@ ReturnValue_t PlocSupvUartManager::initializeInterface(CookieIF* cookie) {
} }
// Flush received and unread data // Flush received and unread data
tcflush(serialPort, TCIOFLUSH); tcflush(serialPort, TCIOFLUSH);
sif::debug << "serial port: " << serialPort << std::endl;
return OK; return OK;
} }
@ -98,9 +97,10 @@ ReturnValue_t PlocSupvUartManager::initialize() {
ReturnValue_t PlocSupvUartManager::performOperation(uint8_t operationCode) { ReturnValue_t PlocSupvUartManager::performOperation(uint8_t operationCode) {
bool putTaskToSleep = false; bool putTaskToSleep = false;
while (true) { while (true) {
lock->lockMutex(); {
state = InternalState::SLEEPING; MutexGuard mg(lock);
lock->unlockMutex(); state = InternalState::SLEEPING;
}
semaphore->acquire(); semaphore->acquire();
putTaskToSleep = false; putTaskToSleep = false;
#if OBSW_THREAD_TRACING == 1 #if OBSW_THREAD_TRACING == 1
@ -112,9 +112,11 @@ ReturnValue_t PlocSupvUartManager::performOperation(uint8_t operationCode) {
break; break;
} }
handleUartReception(); handleUartReception();
lock->lockMutex(); InternalState currentState;
InternalState currentState = state; {
lock->unlockMutex(); MutexGuard mg(lock);
currentState = state;
}
switch (currentState) { switch (currentState) {
case InternalState::SLEEPING: case InternalState::SLEEPING:
case InternalState::GO_TO_SLEEP: { case InternalState::GO_TO_SLEEP: {
@ -140,9 +142,7 @@ ReturnValue_t PlocSupvUartManager::performOperation(uint8_t operationCode) {
ReturnValue_t PlocSupvUartManager::handleUartReception() { ReturnValue_t PlocSupvUartManager::handleUartReception() {
ReturnValue_t result = OK; ReturnValue_t result = OK;
ReturnValue_t status = OK; ReturnValue_t status = OK;
sif::debug << "reading port " << serialPort << std::endl; ssize_t bytesRead = read(serialPort, reinterpret_cast<void*>(recBuf.data()),
TaskFactory::delayTask(100);
ssize_t bytesRead = read(302, reinterpret_cast<void*>(recBuf.data()),
static_cast<unsigned int>(recBuf.size())); static_cast<unsigned int>(recBuf.size()));
if (bytesRead == 0) { if (bytesRead == 0) {
while (result != NO_PACKET_FOUND) { while (result != NO_PACKET_FOUND) {
@ -160,7 +160,7 @@ ReturnValue_t PlocSupvUartManager::handleUartReception() {
<< " bytes" << std::endl; << " bytes" << std::endl;
return FAILED; return FAILED;
} else if (bytesRead > 0) { } else if (bytesRead > 0) {
if (debugMode) { if (DEBUG_MODE) {
sif::info << "Received " << bytesRead << " bytes from the PLOC Supervisor:" << std::endl; sif::info << "Received " << bytesRead << " bytes from the PLOC Supervisor:" << std::endl;
arrayprinter::print(recBuf.data(), bytesRead); arrayprinter::print(recBuf.data(), bytesRead);
} }
@ -575,7 +575,7 @@ ReturnValue_t PlocSupvUartManager::handlePacketTransmissionNoReply(
size_t packetLen = 0; size_t packetLen = 0;
decodedQueue.retrieve(&packetLen); decodedQueue.retrieve(&packetLen);
decodedRingBuf.readData(decodedBuf.data(), packetLen, true); decodedRingBuf.readData(decodedBuf.data(), packetLen, true);
tmReader.setData(decodedBuf.data(), packetLen); tmReader.setReadOnlyData(decodedBuf.data(), packetLen);
result = checkReceivedTm(); result = checkReceivedTm();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
continue; continue;
@ -621,7 +621,7 @@ int PlocSupvUartManager::handleAckReception(supv::TcBase& tc, size_t packetLen)
if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::ACK) or if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::ACK) or
serviceId == static_cast<uint8_t>(supv::tm::TmtcId::NAK)) { serviceId == static_cast<uint8_t>(supv::tm::TmtcId::NAK)) {
AcknowledgmentReport ackReport(tmReader); AcknowledgmentReport ackReport(tmReader);
ReturnValue_t result = ackReport.parse(); ReturnValue_t result = ackReport.parse(false);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
triggerEvent(ACK_RECEPTION_FAILURE); triggerEvent(ACK_RECEPTION_FAILURE);
return -1; return -1;
@ -631,7 +631,7 @@ int PlocSupvUartManager::handleAckReception(supv::TcBase& tc, size_t packetLen)
if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::ACK)) { if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::ACK)) {
return 1; return 1;
} else if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::NAK)) { } else if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::NAK)) {
ackReport.printStatusInformation(); ackReport.printStatusInformationAck();
triggerEvent( triggerEvent(
SUPV_ACK_FAILURE_REPORT, SUPV_ACK_FAILURE_REPORT,
buildApidServiceParam1(ackReport.getRefModuleApid(), ackReport.getRefServiceId()), buildApidServiceParam1(ackReport.getRefModuleApid(), ackReport.getRefServiceId()),
@ -653,7 +653,7 @@ int PlocSupvUartManager::handleExeAckReception(supv::TcBase& tc, size_t packetLe
if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK) or if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK) or
serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_NAK)) { serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_NAK)) {
ExecutionReport exeReport(tmReader); ExecutionReport exeReport(tmReader);
ReturnValue_t result = exeReport.parse(); ReturnValue_t result = exeReport.parse(false);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
triggerEvent(EXE_RECEPTION_FAILURE); triggerEvent(EXE_RECEPTION_FAILURE);
return -1; return -1;
@ -663,7 +663,7 @@ int PlocSupvUartManager::handleExeAckReception(supv::TcBase& tc, size_t packetLe
if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK)) { if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK)) {
return 1; return 1;
} else if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_NAK)) { } else if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_NAK)) {
exeReport.printStatusInformation(); exeReport.printStatusInformationExe();
triggerEvent( triggerEvent(
SUPV_EXE_FAILURE_REPORT, SUPV_EXE_FAILURE_REPORT,
buildApidServiceParam1(exeReport.getRefModuleApid(), exeReport.getRefServiceId()), buildApidServiceParam1(exeReport.getRefModuleApid(), exeReport.getRefServiceId()),
@ -686,7 +686,7 @@ ReturnValue_t PlocSupvUartManager::checkReceivedTm() {
triggerEvent(SUPV_REPLY_SIZE_MISSMATCH, rememberApid); triggerEvent(SUPV_REPLY_SIZE_MISSMATCH, rememberApid);
return result; return result;
} }
if (not tmReader.verifyCrc()) { if (tmReader.checkCrc() != returnvalue::OK) {
triggerEvent(SUPV_REPLY_CRC_MISSMATCH, rememberApid); triggerEvent(SUPV_REPLY_CRC_MISSMATCH, rememberApid);
return result; return result;
} }
@ -762,7 +762,7 @@ ReturnValue_t PlocSupvUartManager::handleCheckMemoryCommand(uint8_t failStep) {
size_t packetLen = 0; size_t packetLen = 0;
decodedQueue.retrieve(&packetLen); decodedQueue.retrieve(&packetLen);
decodedRingBuf.readData(decodedBuf.data(), packetLen, true); decodedRingBuf.readData(decodedBuf.data(), packetLen, true);
tmReader.setData(decodedBuf.data(), packetLen); tmReader.setReadOnlyData(decodedBuf.data(), packetLen);
result = checkReceivedTm(); result = checkReceivedTm();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
continue; continue;
@ -790,7 +790,7 @@ ReturnValue_t PlocSupvUartManager::handleCheckMemoryCommand(uint8_t failStep) {
} else if (tmReader.getModuleApid() == Apid::MEM_MAN) { } else if (tmReader.getModuleApid() == Apid::MEM_MAN) {
if (ackReceived) { if (ackReceived) {
supv::UpdateStatusReport report(tmReader); supv::UpdateStatusReport report(tmReader);
result = report.parse(); result = report.parse(false);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
@ -966,12 +966,10 @@ ReturnValue_t PlocSupvUartManager::handleRunningLongerRequest() {
ReturnValue_t PlocSupvUartManager::encodeAndSendPacket(const uint8_t* sendData, size_t sendLen) { ReturnValue_t PlocSupvUartManager::encodeAndSendPacket(const uint8_t* sendData, size_t sendLen) {
size_t encodedLen = 0; size_t encodedLen = 0;
addHdlcFraming(sendData, sendLen, encodedSendBuf.data(), &encodedLen, encodedSendBuf.size()); addHdlcFraming(sendData, sendLen, encodedSendBuf.data(), &encodedLen, encodedSendBuf.size());
if (printTc) { if (PRINT_TC) {
sif::debug << "Sending TC" << std::endl; sif::debug << "Sending TC" << std::endl;
arrayprinter::print(encodedSendBuf.data(), encodedLen); arrayprinter::print(encodedSendBuf.data(), encodedLen);
} }
sif::debug << "writing to serial port: " << serialPort << std::endl;
TaskFactory::delayTask(50);
size_t bytesWritten = write(serialPort, encodedSendBuf.data(), encodedLen); size_t bytesWritten = write(serialPort, encodedSendBuf.data(), encodedLen);
if (bytesWritten != encodedLen) { if (bytesWritten != encodedLen) {
sif::warning sif::warning
@ -990,6 +988,9 @@ ReturnValue_t PlocSupvUartManager::readReceivedMessage(CookieIF* cookie, uint8_t
return OK; return OK;
} }
ipcQueue.retrieve(size); ipcQueue.retrieve(size);
if (*size > ipcBuffer.size()) {
return FAILED;
}
*buffer = ipcBuffer.data(); *buffer = ipcBuffer.data();
ReturnValue_t result = ipcRingBuf.readData(ipcBuffer.data(), *size, true); ReturnValue_t result = ipcRingBuf.readData(ipcBuffer.data(), *size, true);
if (result != OK) { if (result != OK) {
@ -1090,11 +1091,14 @@ void PlocSupvUartManager::performUartShutdown() {
while (not decodedQueue.empty()) { while (not decodedQueue.empty()) {
decodedQueue.pop(); decodedQueue.pop();
} }
MutexGuard mg(ipcLock); {
ipcRingBuf.clear(); MutexGuard mg0(ipcLock);
while (not ipcQueue.empty()) { ipcRingBuf.clear();
ipcQueue.pop(); while (not ipcQueue.empty()) {
ipcQueue.pop();
}
} }
MutexGuard mg1(lock);
state = InternalState::GO_TO_SLEEP; state = InternalState::GO_TO_SLEEP;
} }

View File

@ -282,8 +282,8 @@ class PlocSupvUartManager : public DeviceCommunicationIF,
std::array<uint8_t, supv::MAX_COMMAND_SIZE> tmBuf{}; std::array<uint8_t, supv::MAX_COMMAND_SIZE> tmBuf{};
bool printTc = true; static constexpr bool PRINT_TC = false;
bool debugMode = true; static constexpr bool DEBUG_MODE = false;
bool timestamping = true; bool timestamping = true;
// Remembers APID to know at which command a procedure failed // Remembers APID to know at which command a procedure failed

View File

@ -556,15 +556,6 @@ class TmBase : public ploc::SpTmReader {
} }
} }
bool verifyCrc() {
if (checkCrc() == returnvalue::OK) {
crcOk = true;
}
return crcOk;
}
bool crcIsOk() const { return crcOk; }
uint8_t getServiceId() const { return getPacketData()[TIMESTAMP_LEN]; } uint8_t getServiceId() const { return getPacketData()[TIMESTAMP_LEN]; }
uint16_t getModuleApid() const { return getApid() & APID_MODULE_MASK; } uint16_t getModuleApid() const { return getApid() & APID_MODULE_MASK; }
@ -576,9 +567,6 @@ class TmBase : public ploc::SpTmReader {
} }
return 0; return 0;
} }
private:
bool crcOk = false;
}; };
class NoPayloadPacket : public TcBase { class NoPayloadPacket : public TcBase {
@ -786,8 +774,6 @@ class SetRestartTries : public TcBase {
} }
private: private:
uint8_t restartTries = 0;
void initPacket(uint8_t restartTries) { payloadStart[0] = restartTries; } void initPacket(uint8_t restartTries) { payloadStart[0] = restartTries; }
}; };
@ -848,8 +834,6 @@ class LatchupAlert : public TcBase {
} }
private: private:
uint8_t latchupId = 0;
void initPacket(uint8_t latchupId) { payloadStart[0] = latchupId; } void initPacket(uint8_t latchupId) { payloadStart[0] = latchupId; }
}; };
@ -879,9 +863,6 @@ class SetAlertlimit : public TcBase {
} }
private: private:
uint8_t latchupId = 0;
uint32_t dutycycle = 0;
ReturnValue_t initPacket(uint8_t latchupId, uint32_t dutycycle) { ReturnValue_t initPacket(uint8_t latchupId, uint32_t dutycycle) {
payloadStart[0] = latchupId; payloadStart[0] = latchupId;
size_t serLen = 0; size_t serLen = 0;
@ -1312,8 +1293,8 @@ class VerificationReport {
virtual ~VerificationReport() = default; virtual ~VerificationReport() = default;
virtual ReturnValue_t parse() { virtual ReturnValue_t parse(bool checkCrc) {
if (not readerBase.crcIsOk()) { if (checkCrc and readerBase.checkCrc() != returnvalue::OK) {
return result::CRC_FAILURE; return result::CRC_FAILURE;
} }
if (readerBase.getModuleApid() != Apid::TMTC_MAN) { if (readerBase.getModuleApid() != Apid::TMTC_MAN) {
@ -1330,27 +1311,27 @@ class VerificationReport {
ReturnValue_t result = SerializeAdapter::deSerialize(&refApid, &payloadStart, &remLen, ReturnValue_t result = SerializeAdapter::deSerialize(&refApid, &payloadStart, &remLen,
SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::debug << "VerificationReport: Failed to deserialize reference APID field" << std::endl; sif::warning << "VerificationReport: Failed to deserialize reference APID field" << std::endl;
return result; return result;
} }
result = SerializeAdapter::deSerialize(&refServiceId, &payloadStart, &remLen, result = SerializeAdapter::deSerialize(&refServiceId, &payloadStart, &remLen,
SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::debug << "VerificationReport: Failed to deserialize reference Service ID field" sif::warning << "VerificationReport: Failed to deserialize reference Service ID field"
<< std::endl; << std::endl;
return result; return result;
} }
result = SerializeAdapter::deSerialize(&refSeqCount, &payloadStart, &remLen, result = SerializeAdapter::deSerialize(&refSeqCount, &payloadStart, &remLen,
SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::debug << "VerificationReport: Failed to deserialize reference sequence count field" sif::warning << "VerificationReport: Failed to deserialize reference sequence count field"
<< std::endl; << std::endl;
return result; return result;
} }
result = SerializeAdapter::deSerialize(&statusCode, &payloadStart, &remLen, result = SerializeAdapter::deSerialize(&statusCode, &payloadStart, &remLen,
SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::debug << "VerificationReport: Failed to deserialize status code field" << std::endl; sif::warning << "VerificationReport: Failed to deserialize status code field" << std::endl;
return result; return result;
} }
return returnvalue::OK; return returnvalue::OK;
@ -1367,7 +1348,7 @@ class VerificationReport {
uint32_t getStatusCode() const { return statusCode; } uint32_t getStatusCode() const { return statusCode; }
virtual void printStatusInformation(const char* prefix) { virtual void printStatusInformation(const char* prefix) const {
bool codeHandled = true; bool codeHandled = true;
if (statusCode < 0x100) { if (statusCode < 0x100) {
GeneralStatusCode code = static_cast<GeneralStatusCode>(getStatusCode()); GeneralStatusCode code = static_cast<GeneralStatusCode>(getStatusCode());
@ -1654,15 +1635,15 @@ class AcknowledgmentReport : public VerificationReport {
public: public:
AcknowledgmentReport(TmBase& readerBase) : VerificationReport(readerBase) {} AcknowledgmentReport(TmBase& readerBase) : VerificationReport(readerBase) {}
virtual ReturnValue_t parse() override { ReturnValue_t parse(bool checkCrc) override {
if (readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::ACK) and if (readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::ACK) and
readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::NAK)) { readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::NAK)) {
return result::INVALID_SERVICE_ID; return result::INVALID_SERVICE_ID;
} }
return VerificationReport::parse(); return VerificationReport::parse(checkCrc);
} }
void printStatusInformation() { void printStatusInformationAck() {
VerificationReport::printStatusInformation(STATUS_PRINTOUT_PREFIX); VerificationReport::printStatusInformation(STATUS_PRINTOUT_PREFIX);
} }
@ -1676,15 +1657,15 @@ class ExecutionReport : public VerificationReport {
TmBase& getReader() { return readerBase; } TmBase& getReader() { return readerBase; }
ReturnValue_t parse() override { ReturnValue_t parse(bool checkCrc) override {
if (readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::EXEC_ACK) and if (readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::EXEC_ACK) and
readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::EXEC_NAK)) { readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::EXEC_NAK)) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
return VerificationReport::parse(); return VerificationReport::parse(checkCrc);
} }
void printStatusInformation() { void printStatusInformationExe() {
VerificationReport::printStatusInformation(STATUS_PRINTOUT_PREFIX); VerificationReport::printStatusInformation(STATUS_PRINTOUT_PREFIX);
} }
@ -1696,8 +1677,8 @@ class UpdateStatusReport {
public: public:
UpdateStatusReport(TmBase& tmReader) : tmReader(tmReader) {} UpdateStatusReport(TmBase& tmReader) : tmReader(tmReader) {}
ReturnValue_t parse() { ReturnValue_t parse(bool checkCrc) {
if (not tmReader.crcIsOk()) { if (checkCrc and tmReader.checkCrc() != returnvalue::OK) {
return result::CRC_FAILURE; return result::CRC_FAILURE;
} }
if (tmReader.getModuleApid() != Apid::MEM_MAN) { if (tmReader.getModuleApid() != Apid::MEM_MAN) {

View File

@ -104,10 +104,6 @@ class SpTmReader : public SpacePacketReader {
*/ */
SpTmReader(const uint8_t* buf, size_t maxSize) : SpacePacketReader(buf, maxSize) {} SpTmReader(const uint8_t* buf, size_t maxSize) : SpacePacketReader(buf, maxSize) {}
ReturnValue_t setData(const uint8_t* buf, size_t maxSize) {
return setReadOnlyData(buf, maxSize);
}
ReturnValue_t checkCrc() const { ReturnValue_t checkCrc() const {
if (CRC::crc16ccitt(getFullData(), getFullPacketLen()) != 0) { if (CRC::crc16ccitt(getFullData(), getFullPacketLen()) != 0) {
return returnvalue::FAILED; return returnvalue::FAILED;