countdown based timeout
This commit is contained in:
@ -268,7 +268,7 @@ static const uint32_t ADC_REPORT_SET_ID = REQUEST_ADC_REPORT;
|
||||
namespace recv_timeout {
|
||||
// Erase memory can require up to 60 seconds for execution
|
||||
static const uint32_t ERASE_MEMORY = 60000;
|
||||
static const uint32_t UPDATE_STATUS_REPORT = 60000;
|
||||
static const uint32_t UPDATE_STATUS_REPORT = 70000;
|
||||
} // namespace recv_timeout
|
||||
|
||||
/**
|
||||
@ -1163,7 +1163,7 @@ class WriteMemory : public SupvTcSpacePacket {
|
||||
SerializeIF::Endianness::BIG);
|
||||
std::memcpy(dataFieldPtr, updateData, length);
|
||||
if (length % 2 != 0) {
|
||||
this->setPacketDataLength(this->getFullSize() + 1);
|
||||
this->setPacketDataLength(length + sizeof(CCSDSPrimaryHeader) + CRC_SIZE - 1);
|
||||
// The data field must be two bytes aligned. Thus, in case the number of bytes to write is odd
|
||||
// a value of zero is added here
|
||||
*(dataFieldPtr + length + 1) = 0;
|
||||
|
@ -402,7 +402,7 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
|
||||
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);
|
||||
@ -546,6 +546,8 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
|
||||
<< " not in replyMap" << std::endl;
|
||||
}
|
||||
|
||||
setExecutionTimeout(command->first);
|
||||
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
@ -795,6 +797,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);
|
||||
@ -1237,7 +1252,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;
|
||||
}
|
||||
|
@ -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"
|
||||
@ -78,6 +79,10 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
|
||||
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];
|
||||
|
||||
@ -128,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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user