ploc update
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
@ -1,28 +1,32 @@
|
||||
#include "PlocSupervisorHandler.h"
|
||||
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <fsfw/globalfunctions/CRC.h>
|
||||
#include <fsfw/timemanager/Clock.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "eive/definitions.h"
|
||||
#include "fsfw/datapool/PoolReadGuard.h"
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "fsfw/timemanager/Clock.h"
|
||||
|
||||
PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid,
|
||||
CookieIF* comCookie, Gpio uartIsolatorSwitch,
|
||||
power::Switch_t powerSwitch)
|
||||
power::Switch_t powerSwitch,
|
||||
PlocSupvHelper* supvHelper)
|
||||
: DeviceHandlerBase(objectId, uartComIFid, comCookie),
|
||||
uartIsolatorSwitch(uartIsolatorSwitch),
|
||||
hkset(this),
|
||||
bootStatusReport(this),
|
||||
latchupStatusReport(this),
|
||||
powerSwitch(powerSwitch) {
|
||||
powerSwitch(powerSwitch),
|
||||
supvHelper(supvHelper) {
|
||||
if (comCookie == NULL) {
|
||||
sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl;
|
||||
}
|
||||
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
||||
}
|
||||
|
||||
PlocSupervisorHandler::~PlocSupervisorHandler() {}
|
||||
@ -38,12 +42,85 @@ ReturnValue_t PlocSupervisorHandler::initialize() {
|
||||
sif::warning << "PlocSupervisorHandler::initialize: Invalid uart com if" << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
#ifdef TE0720_1CFA
|
||||
#ifndef TE0720_1CFA
|
||||
sdcMan = SdCardManager::instance();
|
||||
#endif /* BOARD_TE0720 == 0 */
|
||||
#endif /* TE0720_1CFA */
|
||||
if (supvHelper == nullptr) {
|
||||
sif::warning << "PlocSupervisorHandler::initialize: Invalid supervisor helper" << std::endl;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
result = supvHelper->setComIF(uartComIf);
|
||||
if (result != RETURN_OK) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
supvHelper->setComCookie(comCookie);
|
||||
|
||||
result = eventSubscription();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::performOperationHook() {
|
||||
EventMessage event;
|
||||
for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK;
|
||||
result = eventQueue->receiveMessage(&event)) {
|
||||
switch (event.getMessageId()) {
|
||||
case EventMessage::EVENT_MESSAGE:
|
||||
handleEvent(&event);
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHandler::performOperationHook: Did not subscribe to this event"
|
||||
<< " message" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
switch (actionId) {
|
||||
case supv::TERMINATE_SUPV_HELPER: {
|
||||
supvHelper->stopProcess();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (plocSupvHelperExecuting) {
|
||||
return SupvReturnValuesIF::SUPV_HELPER_EXECUTING;
|
||||
}
|
||||
|
||||
switch (actionId) {
|
||||
case supv::PERFORM_UPDATE: {
|
||||
if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
||||
return SupvReturnValuesIF::FILENAME_TOO_LONG;
|
||||
}
|
||||
std::string file = "";
|
||||
uint8_t memoryId = 0;
|
||||
uint32_t startAddress = 0;
|
||||
result = extractUpdateCommand(data, size, &file, &memoryId, &startAddress);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = supvHelper->startUpdate(file, memoryId, startAddress);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
plocSupvHelperExecuting = true;
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size);
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::doStartUp() {
|
||||
setMode(_MODE_TO_ON);
|
||||
uartIsolatorSwitch.pullHigh();
|
||||
@ -249,16 +326,6 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
|
||||
result = RETURN_OK;
|
||||
break;
|
||||
}
|
||||
case (supv::UPDATE_AVAILABLE):
|
||||
case (supv::UPDATE_IMAGE_DATA):
|
||||
case (supv::UPDATE_VERIFY):
|
||||
// Simply forward data from PLOC Updater to supervisor
|
||||
std::memcpy(commandBuffer, commandData, commandDataLen);
|
||||
rawPacket = commandBuffer;
|
||||
rawPacketLen = commandDataLen;
|
||||
nextReplyId = supv::ACK_REPORT;
|
||||
result = RETURN_OK;
|
||||
break;
|
||||
case (supv::PREPARE_UPDATE): {
|
||||
prepareEmptyCmd(supv::APID_PREPARE_UPDATE);
|
||||
result = RETURN_OK;
|
||||
@ -308,9 +375,6 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
|
||||
this->insertInCommandMap(supv::SET_TIME_REF);
|
||||
this->insertInCommandMap(supv::DISABLE_PERIOIC_HK_TRANSMISSION);
|
||||
this->insertInCommandMap(supv::GET_BOOT_STATUS_REPORT);
|
||||
this->insertInCommandMap(supv::UPDATE_AVAILABLE);
|
||||
this->insertInCommandMap(supv::UPDATE_VERIFY);
|
||||
this->insertInCommandMap(supv::UPDATE_IMAGE_DATA);
|
||||
this->insertInCommandMap(supv::WATCHDOGS_ENABLE);
|
||||
this->insertInCommandMap(supv::WATCHDOGS_CONFIG_TIMEOUT);
|
||||
this->insertInCommandMap(supv::ENABLE_LATCHUP_ALERT);
|
||||
@ -398,7 +462,7 @@ ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t r
|
||||
default: {
|
||||
sif::debug << "PlocSupervisorHandler::scanForReply: Reply has invalid apid" << std::endl;
|
||||
*foundLen = remainingSize;
|
||||
return INVALID_APID;
|
||||
return SupvReturnValuesIF::INVALID_APID;
|
||||
}
|
||||
}
|
||||
|
||||
@ -501,6 +565,19 @@ ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::handleEvent(EventMessage* eventMessage) {
|
||||
object_id_t objectId = eventMessage->getReporter();
|
||||
switch (objectId) {
|
||||
case objects::PLOC_SUPERVISOR_HELPER: {
|
||||
plocSupvHelperExecuting = false;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHandler::handleEvent: Did not subscribe to this event" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
|
||||
uint8_t expectedReplies,
|
||||
bool useAlternateId,
|
||||
@ -568,9 +645,6 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
|
||||
case supv::SET_MAX_RESTART_TRIES:
|
||||
case supv::RESET_MPSOC:
|
||||
case supv::SET_TIME_REF:
|
||||
case supv::UPDATE_AVAILABLE:
|
||||
case supv::UPDATE_IMAGE_DATA:
|
||||
case supv::UPDATE_VERIFY:
|
||||
case supv::WATCHDOGS_ENABLE:
|
||||
case supv::WATCHDOGS_CONFIG_TIMEOUT:
|
||||
case supv::ENABLE_LATCHUP_ALERT:
|
||||
@ -634,7 +708,7 @@ ReturnValue_t PlocSupervisorHandler::verifyPacket(const uint8_t* start, size_t f
|
||||
uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1);
|
||||
uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2);
|
||||
if (receivedCrc != recalculatedCrc) {
|
||||
return CRC_FAILURE;
|
||||
return SupvReturnValuesIF::CRC_FAILURE;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
@ -643,12 +717,12 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
result = verifyPacket(data, supv::SIZE_ACK_REPORT);
|
||||
if (result == CRC_FAILURE) {
|
||||
if (result == SupvReturnValuesIF::CRC_FAILURE) {
|
||||
sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl;
|
||||
nextReplyId = supv::NONE;
|
||||
replyRawReplyIfnotWiretapped(data, supv::SIZE_ACK_REPORT);
|
||||
triggerEvent(SUPV_CRC_FAILURE_EVENT);
|
||||
sendFailureReport(supv::ACK_REPORT, CRC_FAILURE);
|
||||
sendFailureReport(supv::ACK_REPORT, SupvReturnValuesIF::CRC_FAILURE);
|
||||
disableAllReplies();
|
||||
return RETURN_OK;
|
||||
}
|
||||
@ -664,7 +738,7 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) {
|
||||
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
||||
triggerEvent(SUPV_ACK_FAILURE, commandId);
|
||||
}
|
||||
sendFailureReport(supv::ACK_REPORT, RECEIVED_ACK_FAILURE);
|
||||
sendFailureReport(supv::ACK_REPORT, SupvReturnValuesIF::RECEIVED_ACK_FAILURE);
|
||||
disableAllReplies();
|
||||
nextReplyId = supv::NONE;
|
||||
result = IGNORE_REPLY_DATA;
|
||||
@ -689,7 +763,7 @@ ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data)
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
result = verifyPacket(data, supv::SIZE_EXE_REPORT);
|
||||
if (result == CRC_FAILURE) {
|
||||
if (result == SupvReturnValuesIF::CRC_FAILURE) {
|
||||
sif::error << "PlocSupervisorHandler::handleExecutionReport: CRC failure" << std::endl;
|
||||
nextReplyId = supv::NONE;
|
||||
return result;
|
||||
@ -715,7 +789,7 @@ ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data)
|
||||
}
|
||||
uint16_t status = *(data + EXE_STATUS_OFFSET) << 8 | *(data + EXE_STATUS_OFFSET + 1);
|
||||
sif::info << "Execution status: 0x" << std::hex << status << std::endl;
|
||||
sendFailureReport(supv::EXE_REPORT, RECEIVED_EXE_FAILURE);
|
||||
sendFailureReport(supv::EXE_REPORT, SupvReturnValuesIF::RECEIVED_EXE_FAILURE);
|
||||
disableExeReportReply();
|
||||
result = IGNORE_REPLY_DATA;
|
||||
break;
|
||||
@ -737,7 +811,7 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) {
|
||||
|
||||
result = verifyPacket(data, supv::SIZE_HK_REPORT);
|
||||
|
||||
if (result == CRC_FAILURE) {
|
||||
if (result == SupvReturnValuesIF::CRC_FAILURE) {
|
||||
sif::error << "PlocSupervisorHandler::handleHkReport: Hk report has invalid crc" << std::endl;
|
||||
}
|
||||
|
||||
@ -811,7 +885,7 @@ ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data)
|
||||
|
||||
result = verifyPacket(data, supv::SIZE_BOOT_STATUS_REPORT);
|
||||
|
||||
if (result == CRC_FAILURE) {
|
||||
if (result == SupvReturnValuesIF::CRC_FAILURE) {
|
||||
sif::error << "PlocSupervisorHandler::handleBootStatusReport: Boot status report has invalid"
|
||||
" crc"
|
||||
<< std::endl;
|
||||
@ -850,8 +924,8 @@ ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data)
|
||||
<< static_cast<unsigned int>(bootStatusReport.resetCounter.value) << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootAfterMs: "
|
||||
<< bootStatusReport.bootAfterMs << " ms" << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootTimeoutMs: "
|
||||
<< std::dec << bootStatusReport.bootTimeoutMs << " ms" << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootTimeoutMs: " << std::dec
|
||||
<< bootStatusReport.bootTimeoutMs << " ms" << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleBootStatusReport: Active NVM: "
|
||||
<< static_cast<unsigned int>(bootStatusReport.activeNvm.value) << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP0: "
|
||||
@ -861,9 +935,9 @@ ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data)
|
||||
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP2: "
|
||||
<< static_cast<unsigned int>(bootStatusReport.bp2State.value) << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot state: "
|
||||
<< static_cast<unsigned int>(bootStatusReport.bootState.value) << std::endl;
|
||||
<< static_cast<unsigned int>(bootStatusReport.bootState.value) << std::endl;
|
||||
sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot cycles: "
|
||||
<< static_cast<unsigned int>(bootStatusReport.bootCycles.value) << std::endl;
|
||||
<< static_cast<unsigned int>(bootStatusReport.bootCycles.value) << std::endl;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
@ -874,7 +948,7 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da
|
||||
|
||||
result = verifyPacket(data, supv::SIZE_LATCHUP_STATUS_REPORT);
|
||||
|
||||
if (result == CRC_FAILURE) {
|
||||
if (result == SupvReturnValuesIF::CRC_FAILURE) {
|
||||
sif::error << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup status report has "
|
||||
<< "invalid crc" << std::endl;
|
||||
return result;
|
||||
@ -1034,7 +1108,7 @@ void PlocSupervisorHandler::handleDeviceTM(const uint8_t* data, size_t dataSize,
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::prepareEmptyCmd(uint16_t apid) {
|
||||
supv::EmptyPacket packet(apid);
|
||||
supv::ApidOnlyPacket packet(apid);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
}
|
||||
|
||||
@ -1050,7 +1124,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSetTimeRefCmd() {
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocSupervisorHandler::prepareSetTimeRefCmd: Failed to get current time"
|
||||
<< std::endl;
|
||||
return GET_TIME_FAILURE;
|
||||
return SupvReturnValuesIF::GET_TIME_FAILURE;
|
||||
}
|
||||
supv::SetTimeRef packet(&time);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
@ -1091,12 +1165,12 @@ ReturnValue_t PlocSupervisorHandler::prepareWatchdogsConfigTimeoutCmd(const uint
|
||||
uint8_t watchdog = *(commandData + offset);
|
||||
offset += 1;
|
||||
if (watchdog > 2) {
|
||||
return INVALID_WATCHDOG;
|
||||
return SupvReturnValuesIF::INVALID_WATCHDOG;
|
||||
}
|
||||
uint32_t timeout = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 |
|
||||
*(commandData + offset + 2) << 8 | *(commandData + offset + 3);
|
||||
if (timeout < 1000 || timeout > 360000) {
|
||||
return INVALID_WATCHDOG_TIMEOUT;
|
||||
return SupvReturnValuesIF::INVALID_WATCHDOG_TIMEOUT;
|
||||
}
|
||||
supv::WatchdogsConfigTimeout packet(watchdog, timeout);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
@ -1108,7 +1182,7 @@ ReturnValue_t PlocSupervisorHandler::prepareLatchupConfigCmd(const uint8_t* comm
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
uint8_t latchupId = *commandData;
|
||||
if (latchupId > 6) {
|
||||
return INVALID_LATCHUP_ID;
|
||||
return SupvReturnValuesIF::INVALID_LATCHUP_ID;
|
||||
}
|
||||
switch (deviceCommand) {
|
||||
case (supv::ENABLE_LATCHUP_ALERT): {
|
||||
@ -1138,7 +1212,7 @@ ReturnValue_t PlocSupervisorHandler::prepareAutoCalibrateAlertCmd(const uint8_t*
|
||||
uint32_t mg = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 |
|
||||
*(commandData + offset + 2) << 8 | *(commandData + offset + 3);
|
||||
if (latchupId > 6) {
|
||||
return INVALID_LATCHUP_ID;
|
||||
return SupvReturnValuesIF::INVALID_LATCHUP_ID;
|
||||
}
|
||||
supv::AutoCalibrateAlert packet(latchupId, mg);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
@ -1150,7 +1224,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSetAlertIrqFilterCmd(const uint8_t*
|
||||
uint8_t tp = *(commandData + 1);
|
||||
uint8_t div = *(commandData + 2);
|
||||
if (latchupId > 6) {
|
||||
return INVALID_LATCHUP_ID;
|
||||
return SupvReturnValuesIF::INVALID_LATCHUP_ID;
|
||||
}
|
||||
supv::SetAlertIrqFilter packet(latchupId, tp, div);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
@ -1164,7 +1238,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSetAlertLimitCmd(const uint8_t* comm
|
||||
uint32_t dutycycle = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 |
|
||||
*(commandData + offset + 2) << 8 | *(commandData + offset + 3);
|
||||
if (latchupId > 6) {
|
||||
return INVALID_LATCHUP_ID;
|
||||
return SupvReturnValuesIF::INVALID_LATCHUP_ID;
|
||||
}
|
||||
supv::SetAlertlimit packet(latchupId, dutycycle);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
@ -1175,7 +1249,7 @@ ReturnValue_t PlocSupervisorHandler::prepareSetAdcSweetPeriodCmd(const uint8_t*
|
||||
uint32_t sweepPeriod = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 |
|
||||
*(commandData + 3);
|
||||
if (sweepPeriod < 21) {
|
||||
return SWEEP_PERIOD_TOO_SMALL;
|
||||
return SupvReturnValuesIF::SWEEP_PERIOD_TOO_SMALL;
|
||||
}
|
||||
supv::SetAdcSweepPeriod packet(sweepPeriod);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
@ -1220,7 +1294,7 @@ void PlocSupervisorHandler::prepareSelectNvmCmd(const uint8_t* commandData) {
|
||||
ReturnValue_t PlocSupervisorHandler::prepareRunAutoEmTest(const uint8_t* commandData) {
|
||||
uint8_t test = *commandData;
|
||||
if (test != 1 && test != 2) {
|
||||
return INVALID_TEST_PARAM;
|
||||
return SupvReturnValuesIF::INVALID_TEST_PARAM;
|
||||
}
|
||||
supv::RunAutoEmTests packet(test);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
@ -1234,7 +1308,7 @@ ReturnValue_t PlocSupervisorHandler::prepareWipeMramCmd(const uint8_t* commandDa
|
||||
SerializeAdapter::deSerialize(&start, &commandData, &size, SerializeIF::Endianness::BIG);
|
||||
SerializeAdapter::deSerialize(&stop, &commandData, &size, SerializeIF::Endianness::BIG);
|
||||
if ((stop - start) <= 0) {
|
||||
return INVALID_MRAM_ADDRESSES;
|
||||
return SupvReturnValuesIF::INVALID_MRAM_ADDRESSES;
|
||||
}
|
||||
supv::MramCmd packet(start, stop, supv::MramCmd::MramAction::WIPE);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
@ -1250,7 +1324,7 @@ ReturnValue_t PlocSupervisorHandler::prepareDumpMramCmd(const uint8_t* commandDa
|
||||
supv::MramCmd packet(start, stop, supv::MramCmd::MramAction::DUMP);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
if ((stop - start) <= 0) {
|
||||
return INVALID_MRAM_ADDRESSES;
|
||||
return SupvReturnValuesIF::INVALID_MRAM_ADDRESSES;
|
||||
}
|
||||
expectedMramDumpPackets = (stop - start) / supv::MAX_DATA_CAPACITY;
|
||||
if ((stop - start) % supv::MAX_DATA_CAPACITY) {
|
||||
@ -1393,7 +1467,7 @@ ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t* packet, siz
|
||||
*foundLen = remainingSize;
|
||||
disableAllReplies();
|
||||
bufferTop = 0;
|
||||
return MRAM_PACKET_PARSING_FAILURE;
|
||||
return SupvReturnValuesIF::MRAM_PACKET_PARSING_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1477,7 +1551,7 @@ void PlocSupervisorHandler::increaseExpectedMramReplies(DeviceCommandId_t id) {
|
||||
ReturnValue_t PlocSupervisorHandler::checkMramPacketApid() {
|
||||
uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & supv::APID_MASK;
|
||||
if (apid != supv::APID_MRAM_DUMP_TM) {
|
||||
return NO_MRAM_PACKET;
|
||||
return SupvReturnValuesIF::NO_MRAM_PACKET;
|
||||
}
|
||||
return APERIODIC_REPLY;
|
||||
}
|
||||
@ -1498,7 +1572,7 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpFile(DeviceCommandId_t id) {
|
||||
if (not std::filesystem::exists(activeMramFile)) {
|
||||
sif::warning << "PlocSupervisorHandler::handleMramDumpFile: MRAM file does not exist"
|
||||
<< std::endl;
|
||||
return MRAM_FILE_NOT_EXISTS;
|
||||
return SupvReturnValuesIF::MRAM_FILE_NOT_EXISTS;
|
||||
}
|
||||
std::ofstream file(activeMramFile, std::ios_base::app | std::ios_base::out);
|
||||
file.write(reinterpret_cast<const char*>(spacePacketBuffer + supv::SPACE_PACKET_HEADER_LENGTH),
|
||||
@ -1525,7 +1599,7 @@ ReturnValue_t PlocSupervisorHandler::createMramDumpFile() {
|
||||
|
||||
std::string filename = "mram-dump--" + timeStamp + ".bin";
|
||||
|
||||
#ifdef TE0720_1CFA
|
||||
#ifndef TE0720_1CFA
|
||||
std::string currentMountPrefix = sdcMan->getCurrentMountPrefix();
|
||||
#else
|
||||
std::string currentMountPrefix("/mnt/sd0");
|
||||
@ -1535,7 +1609,7 @@ ReturnValue_t PlocSupervisorHandler::createMramDumpFile() {
|
||||
if (not std::filesystem::exists(std::string(currentMountPrefix + "/" + plocFilePath))) {
|
||||
sif::warning << "PlocSupervisorHandler::createMramDumpFile: Ploc path does not exist"
|
||||
<< std::endl;
|
||||
return PATH_DOES_NOT_EXIST;
|
||||
return SupvReturnValuesIF::PATH_DOES_NOT_EXIST;
|
||||
}
|
||||
activeMramFile = currentMountPrefix + "/" + plocFilePath + "/" + filename;
|
||||
// Create new file
|
||||
@ -1551,10 +1625,67 @@ ReturnValue_t PlocSupervisorHandler::getTimeStampString(std::string& timeStamp)
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocSupervisorHandler::createMramDumpFile: Failed to get current time"
|
||||
<< std::endl;
|
||||
return GET_TIME_FAILURE;
|
||||
return SupvReturnValuesIF::GET_TIME_FAILURE;
|
||||
}
|
||||
timeStamp = std::to_string(time.year) + "-" + std::to_string(time.month) + "-" +
|
||||
std::to_string(time.day) + "--" + std::to_string(time.hour) + "-" +
|
||||
std::to_string(time.minute) + "-" + std::to_string(time.second);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::extractUpdateCommand(const uint8_t* commandData, size_t size,
|
||||
std::string* file, uint8_t* memoryId,
|
||||
uint32_t* startAddress) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
if (size > (config::MAX_FILENAME_SIZE + config::MAX_PATH_SIZE + sizeof(*memoryId)) +
|
||||
sizeof(*startAddress)) {
|
||||
sif::warning << "PlocSupervisorHandler::extractUpdateCommand: Data size too big" << std::endl;
|
||||
return SupvReturnValuesIF::INVALID_LENGTH;
|
||||
}
|
||||
*file = std::string(reinterpret_cast<const char*>(commandData));
|
||||
if (file->size() > (config::MAX_FILENAME_SIZE + config::MAX_PATH_SIZE)) {
|
||||
sif::warning << "PlocSupervisorHandler::extractUpdateCommand: Filename too long" << std::endl;
|
||||
return SupvReturnValuesIF::FILENAME_TOO_LONG;
|
||||
}
|
||||
*memoryId = *(commandData + file->size() + SIZE_NULL_TERMINATOR);
|
||||
const uint8_t* startAddressPtr =
|
||||
commandData + file->size() + SIZE_NULL_TERMINATOR + sizeof(*memoryId);
|
||||
size_t remainingSize = 4;
|
||||
result = SerializeAdapter::deSerialize(startAddress, startAddressPtr, &remainingSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning
|
||||
<< "PlocSupervisorHandler::extractUpdateCommand: Failed to deserialize start address"
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::eventSubscription() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
||||
if (manager == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PlocSupervisorHandler::eventSubscritpion: Invalid event manager" << std::endl;
|
||||
#endif
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
;
|
||||
}
|
||||
result = manager->registerListener(eventQueue->getId());
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = manager->subscribeToEventRange(
|
||||
eventQueue->getId(), event::getEventId(PlocSupvHelper::SUPV_UPDATE_FAILED),
|
||||
event::getEventId(PlocSupvHelper::TERMINATED_UPDATE_PROCEDURE));
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "PlocSupervisorHandler::eventSubscritpion: Failed to subscribe to events from "
|
||||
" ploc supervisor helper"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user