bugfix in missed reply hanling of supervsior MRAM dump

This commit is contained in:
Jakob Meier
2022-05-06 19:30:20 +02:00
parent 5c7c5b468a
commit 132751893b
6 changed files with 66 additions and 42 deletions

View File

@ -137,7 +137,6 @@ ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
}
void PlocSupervisorHandler::doStartUp() {
#ifdef XIPHOS_Q7S
switch (startupState) {
case StartupState::OFF: {
bootTimeout.resetTimer();
@ -159,9 +158,6 @@ void PlocSupervisorHandler::doStartUp() {
default:
break;
}
#else
setMode(_MODE_TO_ON);
#endif
}
void PlocSupervisorHandler::doShutDown() {
@ -178,7 +174,7 @@ ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand(DeviceCommandI
if (startupState == StartupState::SET_TIME) {
*id = supv::SET_TIME_REF;
startupState = StartupState::SET_TIME_EXECUTING;
return RETURN_OK;
return buildCommandFromCommand(*id, nullptr, 0);
}
return NOTHING_TO_SEND;
}
@ -436,8 +432,10 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(LOGGING_SET_TOPIC);
this->insertInCommandMap(RESET_PL);
this->insertInCommandMap(ENABLE_NVMS);
this->insertInCommandAndReplyMap(FIRST_MRAM_DUMP, 3);
this->insertInCommandAndReplyMap(CONSECUTIVE_MRAM_DUMP, 3);
this->insertInCommandAndReplyMap(FIRST_MRAM_DUMP, 0, nullptr, 0, false, false, FIRST_MRAM_DUMP,
&mramDumpTimeout);
this->insertInCommandAndReplyMap(CONSECUTIVE_MRAM_DUMP, 0, nullptr, 0, false, false,
CONSECUTIVE_MRAM_DUMP, &mramDumpTimeout);
this->insertInReplyMap(ACK_REPORT, 3, nullptr, SIZE_ACK_REPORT);
this->insertInReplyMap(EXE_REPORT, 0, nullptr, SIZE_EXE_REPORT, false, &executionTimeout);
this->insertInReplyMap(HK_REPORT, 3, &hkset, SIZE_HK_REPORT);
@ -1316,6 +1314,10 @@ ReturnValue_t PlocSupervisorHandler::doSendReadHook() {
return RETURN_OK;
}
void PlocSupervisorHandler::doOffActivity() {
startupState = StartupState::OFF;
}
void PlocSupervisorHandler::handleDeviceTM(const uint8_t* data, size_t dataSize,
DeviceCommandId_t replyId) {
ReturnValue_t result = RETURN_OK;
@ -1548,10 +1550,11 @@ ReturnValue_t PlocSupervisorHandler::prepareEnableNvmsCommand(const uint8_t* com
}
void PlocSupervisorHandler::disableAllReplies() {
using namespace supv;
DeviceReplyMap::iterator iter;
/* Disable ack reply */
iter = deviceReplyMap.find(supv::ACK_REPORT);
iter = deviceReplyMap.find(ACK_REPORT);
DeviceReplyInfo* info = &(iter->second);
info->delayCycles = 0;
info->command = deviceCommandMap.end();
@ -1560,21 +1563,29 @@ void PlocSupervisorHandler::disableAllReplies() {
/* If the command expects a telemetry packet the appropriate tm reply will be disabled here */
switch (commandId) {
case supv::GET_HK_REPORT: {
iter = deviceReplyMap.find(supv::GET_HK_REPORT);
info = &(iter->second);
info->delayCycles = 0;
info->active = false;
info->command = deviceCommandMap.end();
case GET_HK_REPORT: {
disableReply(GET_HK_REPORT);
break;
}
case supv::FIRST_MRAM_DUMP:
case supv::CONSECUTIVE_MRAM_DUMP: {
iter = deviceReplyMap.find(commandId);
info = &(iter->second);
info->delayCycles = 0;
info->active = false;
info->command = deviceCommandMap.end();
case FIRST_MRAM_DUMP:
case CONSECUTIVE_MRAM_DUMP: {
disableReply(commandId);
break;
}
case REQUEST_ADC_REPORT: {
disableReply(ADC_REPORT);
break;
}
case GET_BOOT_STATUS_REPORT: {
disableReply(BOOT_STATUS_REPORT);
break;
}
case GET_LATCHUP_STATUS_REPORT: {
disableReply(LATCHUP_REPORT);
break;
}
case LOGGING_REQUEST_COUNTERS: {
disableReply(LOGGING_REPORT);
break;
}
default: {
@ -1586,6 +1597,14 @@ void PlocSupervisorHandler::disableAllReplies() {
disableExeReportReply();
}
void PlocSupervisorHandler::disableReply(DeviceCommandId_t replyId) {
DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId);
DeviceReplyInfo* info = &(iter->second);
info->delayCycles = 0;
info->active = false;
info->command = deviceCommandMap.end();
}
void PlocSupervisorHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) {
DeviceReplyIter iter = deviceReplyMap.find(replyId);
@ -1663,9 +1682,13 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket(DeviceCommandId_t id)
sif::warning << "PlocSupervisorHandler::handleMramDumpPacket: CRC failure" << std::endl;
return result;
}
handleMramDumpFile(id);
if (downlinkMramDump == true) {
handleDeviceTM(spacePacketBuffer + supv::SPACE_PACKET_HEADER_LENGTH, packetLen - 1, id);
result = handleMramDumpFile(id);
if (result != RETURN_OK) {
DeviceCommandMap::iterator iter = deviceCommandMap.find(id);
actionHelper.finish(false, iter->second.sendReplyTo, id, result);
disableAllReplies();
nextReplyId = supv::NONE;
return result;
}
packetInBuffer = false;
receivedMramDumpPackets++;
@ -1714,23 +1737,19 @@ void PlocSupervisorHandler::increaseExpectedMramReplies(DeviceCommandId_t id) {
(sequenceFlags != static_cast<uint8_t>(supv::SequenceFlags::STANDALONE_PKT))) {
// Command expects at least one MRAM packet more and the execution report
info->expectedReplies = 2;
// Wait maximum of 2 cycles for next MRAM packet
mramReplyInfo->delayCycles = 2;
// Also adapting delay cycles for execution report
exeReplyInfo->delayCycles = 3;
mramReplyInfo->countdown->resetTimer();
} else {
// Command expects the execution report
info->expectedReplies = 1;
mramReplyInfo->delayCycles = 0;
mramReplyInfo->active = false;
}
exeReplyInfo->countdown->resetTimer();
return;
}
ReturnValue_t PlocSupervisorHandler::checkMramPacketApid() {
uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & supv::APID_MASK;
if (apid != supv::APID_MRAM_DUMP_TM) {
sif::warning << "PlocSupervisorHandler::checkMramPacketApid: 0x" << std::hex << apid
<< std::endl;
return SupvReturnValuesIF::NO_MRAM_PACKET;
}
return APERIODIC_REPLY;
@ -1803,7 +1822,7 @@ ReturnValue_t PlocSupervisorHandler::getTimeStampString(std::string& timeStamp)
Clock::TimeOfDay_t time;
ReturnValue_t result = Clock::getDateAndTime(&time);
if (result != RETURN_OK) {
sif::warning << "PlocSupervisorHandler::createMramDumpFile: Failed to get current time"
sif::warning << "PlocSupervisorHandler::getTimeStampString: Failed to get current time"
<< std::endl;
return SupvReturnValuesIF::GET_TIME_FAILURE;
}