From 839851914acf851c5f8ca5220010f86e9b77ca04 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 Aug 2022 16:07:38 +0200 Subject: [PATCH] update SCEX code --- generators/bsp_q7s_events.csv | 4 +- generators/bsp_q7s_returnvalues.csv | 9 +- generators/events/translateEvents.cpp | 10 +- generators/objects/translateObjects.cpp | 2 +- linux/devices/ScexUartReader.cpp | 3 - linux/fsfwconfig/events/translateEvents.cpp | 10 +- linux/fsfwconfig/objects/translateObjects.cpp | 2 +- mission/devices/ScexDeviceHandler.cpp | 133 ++++++++++-------- mission/devices/ScexDeviceHandler.h | 1 + .../devicedefinitions/ScexDefinitions.h | 5 +- tmtc | 2 +- 11 files changed, 103 insertions(+), 78 deletions(-) diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index c7001a82..a38aa4e9 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -215,4 +215,6 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 13701;0x3585;REBOOT_SW;MEDIUM; Software reboot occurred. Can also be a systemd reboot. P1: Current Chip, P2: Current Copy;bsp_q7s/core/CoreController.h 13702;0x3586;REBOOT_MECHANISM_TRIGGERED;MEDIUM;The reboot mechanism was triggered. P1: First 16 bits: Last Chip, Last 16 bits: Last Copy, P2: Each byte is the respective reboot count for the slots;bsp_q7s/core/CoreController.h 13703;0x3587;REBOOT_HW;MEDIUM;;bsp_q7s/core/CoreController.h -13800;0x35e8;EXPERIMENT_TIMEDOUT;LOW;;mission/devices/devicedefinitions/ScexDefinitions.h +13800;0x35e8;MISSING_PACKET;LOW;;mission/devices/devicedefinitions/ScexDefinitions.h +13801;0x35e9;EXPERIMENT_TIMEDOUT;LOW;;mission/devices/devicedefinitions/ScexDefinitions.h +13802;0x35ea;MULTI_PACKET_COMMAND_DONE;INFO;;mission/devices/devicedefinitions/ScexDefinitions.h diff --git a/generators/bsp_q7s_returnvalues.csv b/generators/bsp_q7s_returnvalues.csv index ab196298..7a1e52f8 100644 --- a/generators/bsp_q7s_returnvalues.csv +++ b/generators/bsp_q7s_returnvalues.csv @@ -1,6 +1,6 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path -0x0000;OK;System-wide code for ok.;0;HasReturnvaluesIF;fsfw/returnvalues/HasReturnvaluesIF.h -0x0001;Failed;Unspecified system-wide code for failed.;1;HasReturnvaluesIF;fsfw/returnvalues/HasReturnvaluesIF.h +0x0000;OK;System-wide code for ok.;0;HasReturnvaluesIF;fsfw/returnvalues/returnvalue.h +0x0001;Failed;Unspecified system-wide code for failed.;1;HasReturnvaluesIF;fsfw/returnvalues/returnvalue.h 0x63a0;NVMB_KeyNotExists;Specified key does not exist in json file;160;NVM_PARAM_BASE;mission/memory/NVMParameterBase.h 0x58a0;SUSS_ErrorUnlockMutex;;160;SUS_HANDLER;mission/devices/SusHandler.h 0x58a1;SUSS_ErrorLockMutex;;161;SUS_HANDLER;mission/devices/SusHandler.h @@ -361,8 +361,9 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x2cd2;CCS_TooShortBlockedPacket;;210;CCSDS_HANDLER_IF;fsfw/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h 0x2cd3;CCS_TooShortMapExtraction;;211;CCSDS_HANDLER_IF;fsfw/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h 0x4201;PUS11_InvalidTypeTimeWindow;;1;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h -0x4202;PUS11_TimeshiftingNotPossible;;2;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h -0x4203;PUS11_InvalidRelativeTime;;3;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h +0x4202;PUS11_InvalidTimeWindow;;2;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h +0x4203;PUS11_TimeshiftingNotPossible;;3;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h +0x4204;PUS11_InvalidRelativeTime;;4;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x3401;DC_NoReplyReceived;;1;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h 0x3402;DC_ProtocolError;;2;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h 0x3403;DC_Nullpointer;;3;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index dda8b717..4448112c 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 217 translations. + * @brief Auto-generated event translation file. Contains 219 translations. * @details - * Generated on: 2022-08-24 16:53:50 + * Generated on: 2022-08-31 16:07:07 */ #include "translateEvents.h" @@ -217,7 +217,9 @@ const char *ALLOC_FAILURE_STRING = "ALLOC_FAILURE"; const char *REBOOT_SW_STRING = "REBOOT_SW"; const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED"; const char *REBOOT_HW_STRING = "REBOOT_HW"; +const char *MISSING_PACKET_STRING = "MISSING_PACKET"; const char *EXPERIMENT_TIMEDOUT_STRING = "EXPERIMENT_TIMEDOUT"; +const char *MULTI_PACKET_COMMAND_DONE_STRING = "MULTI_PACKET_COMMAND_DONE"; const char *translateEvents(Event event) { switch ((event & 0xFFFF)) { @@ -646,7 +648,11 @@ const char *translateEvents(Event event) { case (13703): return REBOOT_HW_STRING; case (13800): + return MISSING_PACKET_STRING; + case (13801): return EXPERIMENT_TIMEDOUT_STRING; + case (13802): + return MULTI_PACKET_COMMAND_DONE_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 215d47d8..8f5c084f 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 135 translations. - * Generated on: 2022-08-24 16:53:50 + * Generated on: 2022-08-31 16:07:07 */ #include "translateObjects.h" diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index f1d0d037..57239ed5 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -34,7 +34,6 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { lock->unlockMutex(); while (true) { semaphore->acquire(); - sif::info << "ScexUartReader::performOperation:task was started" << std::endl; int bytesRead = 0; while (true) { bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), @@ -66,8 +65,6 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { } } }; - // task block comes here - sif::info << "ScexUartReader::performOperation: task was stopped" << std::endl; } return OK; } diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index dda8b717..4448112c 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 217 translations. + * @brief Auto-generated event translation file. Contains 219 translations. * @details - * Generated on: 2022-08-24 16:53:50 + * Generated on: 2022-08-31 16:07:07 */ #include "translateEvents.h" @@ -217,7 +217,9 @@ const char *ALLOC_FAILURE_STRING = "ALLOC_FAILURE"; const char *REBOOT_SW_STRING = "REBOOT_SW"; const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED"; const char *REBOOT_HW_STRING = "REBOOT_HW"; +const char *MISSING_PACKET_STRING = "MISSING_PACKET"; const char *EXPERIMENT_TIMEDOUT_STRING = "EXPERIMENT_TIMEDOUT"; +const char *MULTI_PACKET_COMMAND_DONE_STRING = "MULTI_PACKET_COMMAND_DONE"; const char *translateEvents(Event event) { switch ((event & 0xFFFF)) { @@ -646,7 +648,11 @@ const char *translateEvents(Event event) { case (13703): return REBOOT_HW_STRING; case (13800): + return MISSING_PACKET_STRING; + case (13801): return EXPERIMENT_TIMEDOUT_STRING; + case (13802): + return MULTI_PACKET_COMMAND_DONE_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 215d47d8..8f5c084f 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 135 translations. - * Generated on: 2022-08-24 16:53:50 + * Generated on: 2022-08-31 16:07:07 */ #include "translateObjects.h" diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index 2d614765..71bb4302 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -94,9 +94,7 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {commandData + 1, commandDataLen - 1}, tempCheck); - // auto iter = deviceReplyMap.find(FRAM); - // auto& info = iter->second.command->second; - // actionHelper.finish(true,info.sendReplyTo, iter->first, OK); + updatePeriodicReply(true, deviceCommand); break; } case (ONE_CELL): { @@ -105,6 +103,7 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic finishCountdown.resetTimer(); prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {commandData + 1, commandDataLen - 1}, tempCheck); + updatePeriodicReply(true, deviceCommand); break; } case (ALL_CELLS_CMD): { @@ -113,6 +112,7 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic finishCountdown.resetTimer(); prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {commandData + 1, commandDataLen - 1}, tempCheck); + updatePeriodicReply(true, deviceCommand); break; } default: { @@ -130,11 +130,11 @@ void ScexDeviceHandler::fillCommandAndReplyMap() { insertInCommandAndReplyMap(scex::Cmds::TEMP_CMD, 3); insertInCommandAndReplyMap(scex::Cmds::EXP_STATUS_CMD, 3); - insertInCommandAndReplyMap(scex::Cmds::ALL_CELLS_CMD, 0, nullptr, 0, false, false, + insertInCommandAndReplyMap(scex::Cmds::ALL_CELLS_CMD, 0, nullptr, 0, true, false, scex::Cmds::ALL_CELLS_CMD, &finishCountdown); - insertInCommandAndReplyMap(scex::Cmds::ONE_CELL, 0, nullptr, 0, false, false, + insertInCommandAndReplyMap(scex::Cmds::ONE_CELL, 0, nullptr, 0, true, false, scex::Cmds::ONE_CELL, &finishCountdown); - insertInCommandAndReplyMap(scex::Cmds::FRAM, 0, nullptr, 0, false, false, scex::Cmds::FRAM, + insertInCommandAndReplyMap(scex::Cmds::FRAM, 0, nullptr, 0, true, false, scex::Cmds::FRAM, &finishCountdown); insertInReplyMap(scex::Cmds::ERROR_REPLY, 3); @@ -167,6 +167,56 @@ ReturnValue_t ScexDeviceHandler::handleValidReply(size_t remSize, DeviceCommandI size_t* foundLen) { using namespace scex; ReturnValue_t result = OK; + + switch (helper.getCmd()) { + case (FRAM): { + if (debugMode) { + uint32_t remainingMillis = finishCountdown.getRemainingMillis(); + + sif::info << "ScexDeviceHandler::handleValidReply: RemMillis: " << remainingMillis + << std::endl; + } + actionHelper.finish(true, getCommanderQueueId(FRAM), FRAM, result); + result = APERIODIC_REPLY; + break; + } + case (ONE_CELL): { + actionHelper.finish(true, getCommanderQueueId(ONE_CELL), ONE_CELL, result); + result = APERIODIC_REPLY; + break; + } + case (ALL_CELLS_CMD): { + actionHelper.finish(true, getCommanderQueueId(ALL_CELLS_CMD), ALL_CELLS_CMD, result); + result = APERIODIC_REPLY; + break; + } + default: { + break; + } + } + *foundId = helper.getCmd(); + *foundLen = remSize; + return result; +} + +ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + using namespace scex; + + ReturnValue_t status = OK; + auto oneFileHandler = [&](std::string cmdName) { + fileId = date_time_string(); + std::ostringstream oss("/tmp/scex-", std::ostringstream::ate); + oss << cmdName << fileId << ".bin"; + fileName = oss.str(); + ofstream out(fileName, ofstream::binary); + if (out.bad()) { + sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName + << std::endl; + return FAILED; + } + out << helper; + return OK; + }; auto multiFileHandler = [&](std::string cmdName) { if ((helper.getPacketCounter() == 1) or (not fileNameSet)) { fileId = date_time_string(); @@ -191,59 +241,8 @@ ReturnValue_t ScexDeviceHandler::handleValidReply(size_t remSize, DeviceCommandI } out << helper; } - if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { - *foundId = helper.getCmd(); - return OK; - } - return IGNORE_FULL_PACKET; - }; - switch (helper.getCmd()) { - case (FRAM): { - if (debugMode) { - uint32_t remainingMillis = finishCountdown.getRemainingMillis(); - - sif::info << "ScexDeviceHandler::handleValidReply: RemMillis: " << remainingMillis - << std::endl; - } - result = multiFileHandler("fram_"); - break; - } - case (ONE_CELL): { - result = multiFileHandler("one_cell_"); - break; - } - case (ALL_CELLS_CMD): { - result = multiFileHandler("all_cell_"); - break; - } - default: { - *foundId = helper.getCmd(); - break; - } - } - *foundLen = remSize; - return result; -} - -ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { - using namespace scex; - - ReturnValue_t status = OK; - auto oneFileHandler = [&](std::string cmdName) { - fileId = date_time_string(); - std::ostringstream oss("/tmp/scex-", std::ostringstream::ate); - oss << cmdName << fileId << ".bin"; - fileName = oss.str(); - ofstream out(fileName, ofstream::binary); - if (out.bad()) { - sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName - << std::endl; - return FAILED; - } - out << helper; return OK; }; - switch (id) { case (PING): { status = oneFileHandler("ping_"); @@ -261,12 +260,20 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons status = oneFileHandler("exp_status_"); break; } - + case(FRAM): { + status = multiFileHandler("fram_"); + break; + } + case(ONE_CELL): { + status = multiFileHandler("one_cell_"); + break; + } + case(ALL_CELLS_CMD): { + status = multiFileHandler("multi_cell_"); + break; + } default: // Unknown DeviceCommand - if (id == FRAM or id == ONE_CELL or id == ALL_CELLS_CMD) { - break; - } return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { @@ -276,6 +283,10 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons sif::info << "ScexDeviceHandler::interpretDeviceReply:Reader is finished" << std::endl; fileNameSet = false; } + if(id == FRAM or id == ALL_CELLS_CMD or id == ONE_CELL) { + triggerEvent(MULTI_PACKET_COMMAND_DONE, id); + updatePeriodicReply(false, id); + } } if (debugMode) { uint32_t remainingMillis = finishCountdown.getRemainingMillis(); diff --git a/mission/devices/ScexDeviceHandler.h b/mission/devices/ScexDeviceHandler.h index 39d333f5..62973e41 100644 --- a/mission/devices/ScexDeviceHandler.h +++ b/mission/devices/ScexDeviceHandler.h @@ -4,6 +4,7 @@ #include #include #include +#include "commonSubsystemIds.h" class SdCardMountedIF; diff --git a/mission/devices/devicedefinitions/ScexDefinitions.h b/mission/devices/devicedefinitions/ScexDefinitions.h index 685f0cc0..dfa20f3d 100644 --- a/mission/devices/devicedefinitions/ScexDefinitions.h +++ b/mission/devices/devicedefinitions/ScexDefinitions.h @@ -14,8 +14,9 @@ namespace scex { static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SCEX_HANDLER; static constexpr Event MISSING_PACKET = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); - -static constexpr Event EXPERIMENT_TIMEDOUT = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); +static constexpr Event EXPERIMENT_TIMEDOUT = event::makeEvent(SUBSYSTEM_ID, 1, severity::LOW); +//! FRAM, One Cell or All cells command finished. P1: Command ID +static constexpr Event MULTI_PACKET_COMMAND_DONE = event::makeEvent(SUBSYSTEM_ID, 2, severity::INFO); enum Cmds : DeviceCommandId_t { PING = 0b00111, diff --git a/tmtc b/tmtc index b4d4a511..e1d84c5b 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit b4d4a51164af69a22eedd645775061dbb51702b1 +Subproject commit e1d84c5b99e99ea9a9687dcd298d815dc4d8d2b6