adc report

This commit is contained in:
Jakob Meier
2022-04-21 16:30:23 +02:00
parent 0bcb332ce9
commit cf37d74728
5 changed files with 290 additions and 122 deletions

View File

@ -22,6 +22,7 @@ PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t u
bootStatusReport(this),
latchupStatusReport(this),
loggingReport(this),
adcReport(this),
powerSwitch(powerSwitch),
supvHelper(supvHelper) {
if (comCookie == NULL) {
@ -247,6 +248,11 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
result = RETURN_OK;
break;
}
case REQUEST_ADC_REPORT: {
prepareEmptyCmd(APID_REQUEST_ADC_REPORT);
result = RETURN_OK;
break;
}
case RUN_AUTO_EM_TESTS: {
result = prepareRunAutoEmTest(commandData);
break;
@ -319,18 +325,6 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
result = RETURN_OK;
break;
}
case ENABLE_ADC_MONITOR_TASK: {
EnableAdcMonitorTask packet;
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
break;
}
case DISABLE_ADC_MONITOR_TASK: {
DisableAdcMonitorTask packet;
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
break;
}
case LOGGING_REQUEST_COUNTERS: {
RequestLoggingData packet(RequestLoggingData::Sa::REQUEST_COUNTERS);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
@ -387,6 +381,7 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(SET_ADC_THRESHOLD);
this->insertInCommandMap(GET_LATCHUP_STATUS_REPORT);
this->insertInCommandMap(COPY_ADC_DATA_TO_MRAM);
this->insertInCommandMap(REQUEST_ADC_REPORT);
this->insertInCommandMap(RUN_AUTO_EM_TESTS);
this->insertInCommandMap(WIPE_MRAM);
this->insertInCommandMap(PRINT_CPU_STATS);
@ -401,8 +396,6 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(FACTORY_FLASH);
this->insertInCommandMap(ENABLE_AUTO_TM);
this->insertInCommandMap(DISABLE_AUTO_TM);
this->insertInCommandMap(ENABLE_ADC_MONITOR_TASK);
this->insertInCommandMap(DISABLE_ADC_MONITOR_TASK);
this->insertInCommandMap(LOGGING_REQUEST_COUNTERS);
this->insertInCommandMap(LOGGING_CLEAR_COUNTERS);
this->insertInCommandMap(LOGGING_SET_TOPIC);
@ -414,110 +407,120 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
this->insertInReplyMap(BOOT_STATUS_REPORT, 3, &bootStatusReport, SIZE_BOOT_STATUS_REPORT);
this->insertInReplyMap(LATCHUP_REPORT, 3, &latchupStatusReport, SIZE_LATCHUP_STATUS_REPORT);
this->insertInReplyMap(LOGGING_REPORT, 3, &loggingReport, SIZE_LOGGING_REPORT);
this->insertInReplyMap(ADC_REPORT, 3, &adcReport, SIZE_ADC_REPORT);
}
ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
uint8_t expectedReplies,
bool useAlternateId,
DeviceCommandId_t alternateReplyID) {
using namespace supv;
ReturnValue_t result = RETURN_OK;
uint8_t enabledReplies = 0;
switch (command->first) {
case supv::GET_HK_REPORT: {
case GET_HK_REPORT: {
enabledReplies = 3;
result =
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::HK_REPORT);
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, HK_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::HK_REPORT << " not in replyMap" << std::endl;
<< HK_REPORT << " not in replyMap" << std::endl;
}
break;
}
case supv::GET_BOOT_STATUS_REPORT: {
case GET_BOOT_STATUS_REPORT: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
supv::BOOT_STATUS_REPORT);
BOOT_STATUS_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::BOOT_STATUS_REPORT << " not in replyMap" << std::endl;
<< BOOT_STATUS_REPORT << " not in replyMap" << std::endl;
}
break;
}
case supv::GET_LATCHUP_STATUS_REPORT: {
case GET_LATCHUP_STATUS_REPORT: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
supv::LATCHUP_REPORT);
LATCHUP_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::LATCHUP_REPORT << " not in replyMap" << std::endl;
<< LATCHUP_REPORT << " not in replyMap" << std::endl;
}
break;
}
case supv::LOGGING_REQUEST_COUNTERS: {
case LOGGING_REQUEST_COUNTERS: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
supv::LOGGING_REPORT);
LOGGING_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::LOGGING_REPORT << " not in replyMap" << std::endl;
<< LOGGING_REPORT << " not in replyMap" << std::endl;
}
break;
}
case supv::FIRST_MRAM_DUMP: {
case REQUEST_ADC_REPORT: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
ADC_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< ADC_REPORT << " not in replyMap" << std::endl;
}
break;
}
case FIRST_MRAM_DUMP: {
enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
supv::FIRST_MRAM_DUMP);
FIRST_MRAM_DUMP);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::FIRST_MRAM_DUMP << " not in replyMap" << std::endl;
<< FIRST_MRAM_DUMP << " not in replyMap" << std::endl;
}
break;
}
case supv::CONSECUTIVE_MRAM_DUMP: {
case CONSECUTIVE_MRAM_DUMP: {
enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
supv::CONSECUTIVE_MRAM_DUMP);
CONSECUTIVE_MRAM_DUMP);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl;
<< CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl;
}
break;
}
case supv::START_MPSOC:
case supv::SHUTDOWN_MPSOC:
case supv::SEL_MPSOC_BOOT_IMAGE:
case supv::SET_BOOT_TIMEOUT:
case supv::SET_MAX_RESTART_TRIES:
case supv::RESET_MPSOC:
case supv::SET_TIME_REF:
case supv::ENABLE_LATCHUP_ALERT:
case supv::DISABLE_LATCHUP_ALERT:
case supv::SET_ALERT_LIMIT:
case supv::SET_ADC_ENABLED_CHANNELS:
case supv::SET_ADC_WINDOW_AND_STRIDE:
case supv::SET_ADC_THRESHOLD:
case supv::COPY_ADC_DATA_TO_MRAM:
case supv::RUN_AUTO_EM_TESTS:
case supv::WIPE_MRAM:
case supv::PRINT_CPU_STATS:
case supv::SET_GPIO:
case supv::READ_GPIO:
case supv::RESTART_SUPERVISOR:
case supv::FACTORY_RESET_CLEAR_ALL:
case supv::FACTORY_RESET_CLEAR_MIRROR:
case supv::FACTORY_RESET_CLEAR_CIRCULAR:
case supv::DISABLE_PERIOIC_HK_TRANSMISSION:
case supv::START_MPSOC_QUIET:
case supv::SET_SHUTDOWN_TIMEOUT:
case supv::FACTORY_FLASH:
case supv::ENABLE_AUTO_TM:
case supv::DISABLE_AUTO_TM:
case supv::ENABLE_ADC_MONITOR_TASK:
case supv::DISABLE_ADC_MONITOR_TASK:
case supv::LOGGING_CLEAR_COUNTERS:
case supv::LOGGING_SET_TOPIC:
case START_MPSOC:
case SHUTDOWN_MPSOC:
case SEL_MPSOC_BOOT_IMAGE:
case SET_BOOT_TIMEOUT:
case SET_MAX_RESTART_TRIES:
case RESET_MPSOC:
case SET_TIME_REF:
case ENABLE_LATCHUP_ALERT:
case DISABLE_LATCHUP_ALERT:
case SET_ALERT_LIMIT:
case SET_ADC_ENABLED_CHANNELS:
case SET_ADC_WINDOW_AND_STRIDE:
case SET_ADC_THRESHOLD:
case COPY_ADC_DATA_TO_MRAM:
case RUN_AUTO_EM_TESTS:
case WIPE_MRAM:
case PRINT_CPU_STATS:
case SET_GPIO:
case READ_GPIO:
case RESTART_SUPERVISOR:
case FACTORY_RESET_CLEAR_ALL:
case FACTORY_RESET_CLEAR_MIRROR:
case FACTORY_RESET_CLEAR_CIRCULAR:
case DISABLE_PERIOIC_HK_TRANSMISSION:
case START_MPSOC_QUIET:
case SET_SHUTDOWN_TIMEOUT:
case FACTORY_FLASH:
case ENABLE_AUTO_TM:
case DISABLE_AUTO_TM:
case LOGGING_CLEAR_COUNTERS:
case LOGGING_SET_TOPIC:
enabledReplies = 2;
break;
default:
@ -530,16 +533,16 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
* replies will be enabled here.
*/
result =
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::ACK_REPORT);
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, ACK_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " << supv::ACK_REPORT
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " << ACK_REPORT
<< " not in replyMap" << std::endl;
}
result =
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::EXE_REPORT);
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, EXE_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " << supv::EXE_REPORT
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " << EXE_REPORT
<< " not in replyMap" << std::endl;
}
@ -586,6 +589,10 @@ ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t r
*foundLen = SIZE_LOGGING_REPORT;
*foundId = LOGGING_REPORT;
break;
case (APID_ADC_REPORT):
*foundLen = SIZE_ADC_REPORT;
*foundId = ADC_REPORT;
break;
case (APID_EXE_SUCCESS):
*foundLen = SIZE_EXE_REPORT;
*foundId = EXE_REPORT;
@ -616,34 +623,39 @@ ReturnValue_t PlocSupervisorHandler::getSwitches(const uint8_t** switches,
ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t* packet) {
using namespace supv;
ReturnValue_t result = RETURN_OK;
switch (id) {
case supv::ACK_REPORT: {
case ACK_REPORT: {
result = handleAckReport(packet);
break;
}
case (supv::HK_REPORT): {
case (HK_REPORT): {
result = handleHkReport(packet);
break;
}
case (supv::BOOT_STATUS_REPORT): {
case (BOOT_STATUS_REPORT): {
result = handleBootStatusReport(packet);
break;
}
case (supv::LATCHUP_REPORT): {
case (LATCHUP_REPORT): {
result = handleLatchupStatusReport(packet);
break;
}
case (supv::LOGGING_REPORT): {
case (LOGGING_REPORT): {
result = handleLoggingReport(packet);
break;
}
case (supv::FIRST_MRAM_DUMP):
case (supv::CONSECUTIVE_MRAM_DUMP):
case (ADC_REPORT): {
result = handleAdcReport(packet);
break;
}
case (FIRST_MRAM_DUMP):
case (CONSECUTIVE_MRAM_DUMP):
result = handleMramDumpPacket(id);
break;
case (supv::EXE_REPORT): {
case (EXE_REPORT): {
result = handleExecutionReport(packet);
break;
}
@ -712,6 +724,40 @@ ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool
localDataPoolMap.emplace(supv::SOC_BOOTS, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(supv::SOC_BOOT_FAILS, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_0, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_1, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_2, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_3, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_4, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_5, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_6, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_7, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_8, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_9, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_10, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_11, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_12, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_13, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_14, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_RAW_15, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_0, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_1, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_2, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_3, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_4, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_5, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_6, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_7, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_8, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_9, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_10, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_11, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_12, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_13, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_14, new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(supv::ADC_ENG_15, new PoolEntry<uint16_t>({0}));
return HasReturnvaluesIF::RETURN_OK;
}
@ -1071,7 +1117,7 @@ ReturnValue_t PlocSupervisorHandler::handleLoggingReport(const uint8_t* data) {
size_t size = loggingReport.getSerializedSize();
result = loggingReport.deSerialize(&dataField, &size, SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::handleLoggingReport: Deserialization failed" << std::endl;
sif::warning << "PlocSupervisorHandler::handleLoggingReport: Deserialization failed" << std::endl;
}
loggingReport.setValidityBufferGeneration(true);
loggingReport.setValidity(true, true);
@ -1086,6 +1132,41 @@ ReturnValue_t PlocSupervisorHandler::handleLoggingReport(const uint8_t* data) {
return result;
}
ReturnValue_t PlocSupervisorHandler::handleAdcReport(const uint8_t* data) {
ReturnValue_t result = RETURN_OK;
result = verifyPacket(data, supv::SIZE_ADC_REPORT);
if (result == SupvReturnValuesIF::CRC_FAILURE) {
sif::error << "PlocSupervisorHandler::handleAdcReport: ADC report has "
<< "invalid crc" << std::endl;
return result;
}
const uint8_t* dataField = data + supv::DATA_FIELD_OFFSET;
result = adcReport.read();
if (result != RETURN_OK) {
return result;
}
adcReport.setValidityBufferGeneration(false);
size_t size = adcReport.getSerializedSize();
result = adcReport.deSerialize(&dataField, &size, SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::warning << "PlocSupervisorHandler::handleAdcReport: Deserialization failed" << std::endl;
}
adcReport.setValidityBufferGeneration(true);
adcReport.setValidity(true, true);
result = adcReport.commit();
if (result != RETURN_OK) {
return result;
}
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1
adcReport.printSet();
#endif
nextReplyId = supv::EXE_REPORT;
return result;
}
void PlocSupervisorHandler::setNextReplyId() {
switch (getPendingCommand()) {
case supv::GET_HK_REPORT:
@ -1106,6 +1187,9 @@ void PlocSupervisorHandler::setNextReplyId() {
case supv::LOGGING_REQUEST_COUNTERS:
nextReplyId = supv::LOGGING_REPORT;
break;
case supv::REQUEST_ADC_REPORT:
nextReplyId = supv::ADC_REPORT;
break;
default:
/* If no telemetry is expected the next reply is always the execution report */
nextReplyId = supv::EXE_REPORT;