fixed conflicts
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
2022-04-28 18:33:27 +02:00
25 changed files with 1243 additions and 896 deletions

View File

@ -344,6 +344,11 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
result = RETURN_OK;
break;
}
case RESET_PL: {
prepareEmptyCmd(APID_RESET_PL);
result = RETURN_OK;
break;
}
default:
sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented"
<< std::endl;
@ -399,10 +404,11 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(LOGGING_REQUEST_COUNTERS);
this->insertInCommandMap(LOGGING_CLEAR_COUNTERS);
this->insertInCommandMap(LOGGING_SET_TOPIC);
this->insertInCommandMap(RESET_PL);
this->insertInCommandAndReplyMap(FIRST_MRAM_DUMP, 3);
this->insertInCommandAndReplyMap(CONSECUTIVE_MRAM_DUMP, 3);
this->insertInReplyMap(ACK_REPORT, 3, nullptr, SIZE_ACK_REPORT);
this->insertInReplyMap(EXE_REPORT, 50, nullptr, SIZE_EXE_REPORT);
this->insertInReplyMap(EXE_REPORT, 0, nullptr, SIZE_EXE_REPORT, false, &executionTimeout);
this->insertInReplyMap(HK_REPORT, 3, &hkset, SIZE_HK_REPORT);
this->insertInReplyMap(BOOT_STATUS_REPORT, 3, &bootStatusReport, SIZE_BOOT_STATUS_REPORT);
this->insertInReplyMap(LATCHUP_REPORT, 3, &latchupStatusReport, SIZE_LATCHUP_STATUS_REPORT);
@ -521,6 +527,7 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
case DISABLE_AUTO_TM:
case LOGGING_CLEAR_COUNTERS:
case LOGGING_SET_TOPIC:
case RESET_PL:
enabledReplies = 2;
break;
default:
@ -546,6 +553,8 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
<< " not in replyMap" << std::endl;
}
setExecutionTimeout(command->first);
return RETURN_OK;
}
@ -769,10 +778,24 @@ ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool
}
void PlocSupervisorHandler::handleEvent(EventMessage* eventMessage) {
ReturnValue_t result = RETURN_OK;
object_id_t objectId = eventMessage->getReporter();
Event event = eventMessage->getEvent();
switch (objectId) {
case objects::PLOC_SUPERVISOR_HELPER: {
plocSupvHelperExecuting = false;
// After execution of update procedure, PLOC is in a state where it draws approx. 700 mA of
// current. To leave this state the shutdown MPSoC command must be sent here.
if (event == PlocSupvHelper::SUPV_UPDATE_FAILED ||
event == PlocSupvHelper::SUPV_UPDATE_SUCCESSFUL) {
result = this->executeAction(supv::SHUTDOWN_MPSOC, NO_COMMANDER, nullptr, 0);
if (result != RETURN_OK) {
triggerEvent(SUPV_MPSOC_SHUWDOWN_BUILD_FAILED);
sif::warning << "PlocSupervisorHandler::handleEvent: Failed to build MPSoC shutdown "
"command" << std::endl;
return;
}
}
break;
}
default:
@ -781,6 +804,19 @@ void PlocSupervisorHandler::handleEvent(EventMessage* eventMessage) {
}
}
void PlocSupervisorHandler::setExecutionTimeout(DeviceCommandId_t command) {
using namespace supv;
switch(command) {
case FIRST_MRAM_DUMP:
case CONSECUTIVE_MRAM_DUMP:
executionTimeout.setTimeout(MRAM_DUMP_EXECUTION_TIMEOUT);
break;
default:
executionTimeout.setTimeout(EXECUTION_DEFAULT_TIMEOUT);
break;
}
}
ReturnValue_t PlocSupervisorHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1);
uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2);
@ -1223,7 +1259,8 @@ size_t PlocSupervisorHandler::getNextReplyLength(DeviceCommandId_t commandId) {
DeviceReplyIter iter = deviceReplyMap.find(nextReplyId);
if (iter != deviceReplyMap.end()) {
if (iter->second.delayCycles == 0) {
if ((iter->second.delayCycles == 0 && iter->second.countdown == nullptr) ||
(not iter->second.active && iter->second.countdown != nullptr)) {
/* Reply inactive */
return replyLen;
}

View File

@ -8,6 +8,7 @@
#include "fsfw_hal/linux/gpio/Gpio.h"
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h"
#include "fsfw_hal/linux/uart/UartComIF.h"
#include "fsfw/timemanager/Countdown.h"
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
#include "linux/devices/devicedefinitions/SupvReturnValuesIF.h"
#include "PlocSupvHelper.h"
@ -71,11 +72,17 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
static const Event SUPV_CRC_FAILURE_EVENT = MAKE_EVENT(4, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor helper currently executing a command
static const Event SUPV_HELPER_EXECUTING = MAKE_EVENT(5, severity::LOW);
//! [EXPORT] : [COMMENT] Failed to build the command to shutdown the MPSoC
static const Event SUPV_MPSOC_SHUWDOWN_BUILD_FAILED = MAKE_EVENT(5, severity::LOW);
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;
// 30 s
static const uint32_t MRAM_DUMP_EXECUTION_TIMEOUT = 30000;
uint8_t commandBuffer[supv::MAX_COMMAND_SIZE];
@ -126,6 +133,13 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
// Supervisor helper class currently executing a command
bool plocSupvHelperExecuting = false;
Countdown executionTimeout = Countdown(EXECUTION_DEFAULT_TIMEOUT, false);
/**
* @brief Adjusts the timeout of the execution report dependent on command
*/
void setExecutionTimeout(DeviceCommandId_t command);
/**
* @brief Handles event messages received from the supervisor helper
*/

View File

@ -149,7 +149,8 @@ ReturnValue_t PlocSupvHelper::performUpdate() {
return result;
}
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
ProgressPrinter progressPrinter("Supervisor update", update.length, ProgressPrinter::ONE_PERCENT);
ProgressPrinter progressPrinter("Supervisor update", update.length,
ProgressPrinter::HALF_PERCENT);
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
uint8_t tempData[supv::WriteMemory::CHUNK_MAX];
std::ifstream file(update.file, std::ifstream::binary);
@ -172,9 +173,9 @@ ReturnValue_t PlocSupvHelper::performUpdate() {
file.read(reinterpret_cast<char*>(tempData), dataLength);
if (!file) {
sif::warning << "PlocSupvHelper::performUpdate: Read only " << file.gcount() << " of "
<< dataLength << " bytes" << std::endl;
<< dataLength << " bytes" << std::endl;
sif::info << "PlocSupvHelper::performUpdate: Failed when trying to read byte "
<< bytesWritten << std::endl;
<< bytesWritten << std::endl;
}
remainingSize -= dataLength;
} else {
@ -280,64 +281,48 @@ ReturnValue_t PlocSupvHelper::sendCommand(SpacePacket& packet) {
ReturnValue_t PlocSupvHelper::handleAck() {
ReturnValue_t result = RETURN_OK;
supv::TmPacket tmPacket;
result = handleTmReception(&tmPacket, supv::SIZE_ACK_REPORT);
supv::AcknowledgmentReport ackReport;
result = handleTmReception(&ackReport, supv::SIZE_ACK_REPORT);
if (result != RETURN_OK) {
triggerEvent(ACK_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid));
sif::warning << "PlocSupvHelper::handleAck: Error in reception of acknowledgment report"
<< std::endl;
return result;
}
uint16_t apid = tmPacket.getAPID();
if (apid != supv::APID_ACK_SUCCESS) {
handleAckApidFailure(apid);
return RETURN_FAILED;
result = ackReport.checkApid();
if (result != RETURN_OK) {
if (result == SupvReturnValuesIF::RECEIVED_ACK_FAILURE) {
triggerEvent(SUPV_ACK_FAILURE_REPORT, static_cast<uint32_t>(ackReport.getRefApid()));
} else if (result == SupvReturnValuesIF::INVALID_APID) {
triggerEvent(SUPV_ACK_INVALID_APID, static_cast<uint32_t>(rememberApid));
}
return result;
}
return RETURN_OK;
}
void PlocSupvHelper::handleAckApidFailure(uint16_t apid) {
if (apid == supv::APID_ACK_FAILURE) {
triggerEvent(SUPV_ACK_FAILURE_REPORT, static_cast<uint32_t>(internalState));
sif::warning << "PlocSupvHelper::handleAckApidFailure: Received acknowledgement failure "
<< "report" << std::endl;
} else {
triggerEvent(SUPV_ACK_INVALID_APID, apid, static_cast<uint32_t>(internalState));
sif::warning << "PlocSupvHelper::handleAckApidFailure: Expected acknowledgement report "
<< "but received space packet with apid " << std::hex << apid << std::endl;
}
}
ReturnValue_t PlocSupvHelper::handleExe(uint32_t timeout) {
ReturnValue_t result = RETURN_OK;
supv::TmPacket tmPacket;
result = handleTmReception(&tmPacket, supv::SIZE_EXE_REPORT, timeout);
supv::ExecutionReport exeReport;
result = handleTmReception(&exeReport, supv::SIZE_EXE_REPORT, timeout);
if (result != RETURN_OK) {
triggerEvent(EXE_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid));
sif::warning << "PlocSupvHelper::handleExe: Error in reception of execution report"
<< std::endl;
return result;
}
uint16_t apid = tmPacket.getAPID();
if (apid != supv::APID_EXE_SUCCESS) {
handleExeApidFailure(apid);
return RETURN_FAILED;
result = exeReport.checkApid();
if (result != RETURN_OK) {
if (result == SupvReturnValuesIF::RECEIVED_EXE_FAILURE) {
triggerEvent(SUPV_EXE_FAILURE_REPORT, static_cast<uint32_t>(exeReport.getRefApid()));
} else if (result == SupvReturnValuesIF::INVALID_APID) {
triggerEvent(SUPV_EXE_INVALID_APID, static_cast<uint32_t>(rememberApid));
}
return result;
}
return RETURN_OK;
}
void PlocSupvHelper::handleExeApidFailure(uint16_t apid) {
if (apid == supv::APID_EXE_FAILURE) {
triggerEvent(SUPV_EXE_FAILURE_REPORT, static_cast<uint32_t>(internalState));
sif::warning << "PlocSupvHelper::handleExeApidFailure: Received execution failure "
<< "report" << std::endl;
} else {
triggerEvent(SUPV_EXE_INVALID_APID, apid, static_cast<uint32_t>(internalState));
sif::warning << "PlocSupvHelper::handleExeApidFailure: Expected execution report "
<< "but received space packet with apid " << std::hex << apid << std::endl;
}
}
ReturnValue_t PlocSupvHelper::handleTmReception(supv::TmPacket* tmPacket, size_t remainingBytes,
uint32_t timeout) {
ReturnValue_t result = RETURN_OK;
@ -404,7 +389,8 @@ ReturnValue_t PlocSupvHelper::calcImageCrc() {
uint16_t remainder = CRC16_INIT;
uint8_t input;
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1
ProgressPrinter progress("Supervisor update crc calculation", update.length);
ProgressPrinter progress("Supervisor update crc calculation", update.length,
ProgressPrinter::ONE_PERCENT);
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
uint32_t byteCount = 0;
for (byteCount = 0; byteCount < update.length; byteCount++) {
@ -440,9 +426,12 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
static_cast<size_t>(updateStatusReport.getNominalSize()),
supv::recv_timeout::UPDATE_STATUS_REPORT);
if (result != RETURN_OK) {
sif::warning
<< "PlocSupvHelper::handleCheckMemoryCommand: Failed to receive update status report"
<< std::endl;
return result;
}
result = handleExe();
result = handleExe(CRC_EXECUTION_TIMEOUT);
if (result != RETURN_OK) {
return result;
}
@ -452,8 +441,8 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
}
result = updateStatusReport.verifycrc(update.crc);
if (result != RETURN_OK) {
sif::warning << "PlocSupvHelper::performUpdate: CRC failure. Expected CRC 0x" << std::hex
<< update.crc << " but received CRC 0x" << updateStatusReport.getCrc()
sif::warning << "PlocSupvHelper::handleCheckMemoryCommand: CRC failure. Expected CRC 0x"
<< std::hex << update.crc << " but received CRC 0x" << updateStatusReport.getCrc()
<< std::endl;
return result;
}

View File

@ -61,8 +61,8 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
//! [EXPORT] : [COMMENT] Supervisor received acknowledgment failure report
//! P1: Internal state of supervisor helper
static const Event SUPV_ACK_FAILURE_REPORT = MAKE_EVENT(11, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor received execution failure report
//! P1: Internal state of supervisor
//! [EXPORT] : [COMMENT] Execution report failure
//! P1:
static const Event SUPV_EXE_FAILURE_REPORT = MAKE_EVENT(12, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor expected acknowledgment report but received space packet with other apid
//! P1: Apid of received space packet
@ -129,6 +129,7 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
static const uint8_t NUM_EVENT_BUFFER_PACKETS = 25;
static const size_t SIZE_EVENT_BUFFER_FULL_PACKET = 1024;
static const size_t SIZE_EVENT_BUFFER_LAST_PACKET = 200;
static const uint32_t CRC_EXECUTION_TIMEOUT = 60000;
struct Update {
uint8_t memoryId;
@ -190,8 +191,6 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
ReturnValue_t receive(uint8_t* data, size_t* readBytes, size_t requestBytes);
ReturnValue_t handleAck();
ReturnValue_t handleExe(uint32_t timeout = 1000);
void handleAckApidFailure(uint16_t apid);
void handleExeApidFailure(uint16_t apid);
/**
* @brief Handles reading of TM packets from the communication interface
*