get boot status report wip

This commit is contained in:
Jakob.Meier
2021-07-24 13:57:05 +02:00
parent de1f61a804
commit c4616e3633
4 changed files with 125 additions and 11 deletions

View File

@ -6,7 +6,7 @@
#include <fsfw/timemanager/Clock.h>
PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF * comCookie) :
DeviceHandlerBase(objectId, uartComIFid, comCookie), hkset(this) {
DeviceHandlerBase(objectId, uartComIFid, comCookie), hkset(this), bootStatusReport(this) {
if (comCookie == NULL) {
sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl;
}
@ -106,6 +106,11 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(
result = RETURN_OK;
break;
}
case(PLOC_SPV::GET_BOOT_STATUS_REPORT): {
prepareEmptyCmd(PLOC_SPV::APID_GET_BOOT_STATUS_RPT);
result = RETURN_OK;
break;
}
default:
sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented"
<< std::endl;
@ -134,6 +139,7 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(PLOC_SPV::RESET_MPSOC);
this->insertInCommandMap(PLOC_SPV::SET_TIME_REF);
this->insertInCommandMap(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION);
this->insertInCommandMap(PLOC_SPV::GET_BOOT_STATUS_REPORT);
this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT);
this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT);
this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, nullptr, PLOC_SPV::SIZE_HK_REPORT);
@ -191,6 +197,10 @@ ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id,
result = handleHkReport(packet);
break;
}
case (PLOC_SPV::BOOT_STATUS_REPORT): {
result = handleBootStatusReport(packet);
break;
}
case (PLOC_SPV::EXE_REPORT): {
result = handleExecutionReport(packet);
break;
@ -228,6 +238,15 @@ ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool
localDataPoolMap.emplace(PLOC_SPV::CPULOAD, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(PLOC_SPV::AVAILABLEHEAP, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(PLOC_SPV::BOOT_SIGNAL, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(PLOC_SPV::RESET_COUNTER, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(PLOC_SPV::BOOT_AFTER_MS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(PLOC_SPV::BOOT_TIMEOUT_MS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(PLOC_SPV::ACTIVE_NVM, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(PLOC_SPV::BP0_STATE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(PLOC_SPV::BP1_STATE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(PLOC_SPV::BP2_STATE, new PoolEntry<uint8_t>( { 0 }));
return HasReturnvaluesIF::RETURN_OK;
}
@ -408,6 +427,53 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) {
return result;
}
ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data) {
ReturnValue_t result = RETURN_OK;
result = verifyPacket(data, PLOC_SPV::SIZE_BOOT_STATUS_REPORT);
if(result == CRC_FAILURE) {
sif::error << "PlocSupervisorHandler::handleBootStatusReport: Boot status report has invalid"
" crc" << std::endl;
return result;
}
uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET;
bootStatusReport.bootSignal = *(data + offset);
offest += 1;
bootStatusReport.resetCounter = *(data + offset);
offest += 1;
bootStatusReport.bootAfterMs = *(data + offset) << 24 | *(data + offset + 1) << 16 |
*(data + offset + 2) << 8 | *(data + offset + 3);
offest += 4;
bootStatusReport.bootTimeoutMs = *(data + offset) << 24 | *(data + offset + 1) << 16 |
*(data + offset + 2) << 8 | *(data + offset + 3);
offest += 4;
bootStatusReport.activeNvm = *(data + offset);
offest += 1;
bootStatusReport.bp0State = *(data + offset);
offest += 1;
bootStatusReport.bp1State = *(data + offset);
offest += 1;
bootStatusReport.bp2State = *(data + offset);
nextReplyId = PLOC_SPV::EXE_REPORT;
#if OBSW_VERBOSE_LEVEL >= 1 && PLOC_SUPERVISOR_DEBUG == 1
sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot signal: " << static_cast<unsigned int>(bootStatusReport.bootSignal.value) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: Reset counter: " << static_cast<unsigned int>(bootStatusReport.resetCounter.value) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootAfterMs: " << bootStatusReport.bootAfterMs << " ms" << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootTimeoutMs: " << 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: " << static_cast<unsigned int>(bootStatusReport.bp0State) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP1: " << static_cast<unsigned int>(bootStatusReport.bp1State) << std::endl;
sif::info << "PlocSupervisorHandler::handleBootStatusReport: BP2: " << static_cast<unsigned int>(bootStatusReport.bp2State) << std::endl;
#endif
return result;
}
ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
uint8_t expectedReplies, bool useAlternateId,
DeviceCommandId_t alternateReplyID) {