PLOC MPSoC dir content report #634

Merged
meggert merged 54 commits from ploc_mpsoc_dir_content_report_2 into v2.1.0-dev 2023-05-15 09:40:03 +02:00
7 changed files with 620 additions and 77 deletions

View File

@ -33,6 +33,10 @@ will consitute of a breaking change warranting a new major release:
CMake from selecting wrong cross-compilers if multiple cross-compilers with the same name are used CMake from selecting wrong cross-compilers if multiple cross-compilers with the same name are used
on the same system. on the same system.
- Add ACS board for EM by default now. - Add ACS board for EM by default now.
- Add support for MPSoC HK packet.
- Add support for MPSoC Flash Directory Content Report.
- Dynamically enable and disable HK packets for MPSoC on `ON` and `OFF` commands.
- Increase frequency of payload handlers from 0.8 seconds to 0.5 seconds.
## Added ## Added
@ -50,6 +54,8 @@ will consitute of a breaking change warranting a new major release:
without an additional PCDU power switch command. without an additional PCDU power switch command.
- The PLOC Supervisor handler now waits for the replies to the `SET_TIME` command to verify working - The PLOC Supervisor handler now waits for the replies to the `SET_TIME` command to verify working
communication. communication.
- The PLOC MPSoC now waits 10 cycles before going to on. These wait cycles are necessary because
the MPSoC is not ready to process commands without this additional boot time.
- Fixed correction for `GPS Altitude` in case the sensor data is out of the expected bonds. - Fixed correction for `GPS Altitude` in case the sensor data is out of the expected bonds.
# [v2.0.5] 2023-05-11 # [v2.0.5] 2023-05-11

View File

@ -366,7 +366,7 @@ void scheduling::initTasks() {
#endif /* OBSW_ADD_PLOC_SUPERVISOR */ #endif /* OBSW_ADD_PLOC_SUPERVISOR */
PeriodicTaskIF* plTask = factory->createPeriodicTask( PeriodicTaskIF* plTask = factory->createPeriodicTask(
"PL_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc, &RR_SCHEDULING); "PL_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, missedDeadlineFunc, &RR_SCHEDULING);
plTask->addComponent(objects::CAM_SWITCHER); plTask->addComponent(objects::CAM_SWITCHER);
scheduling::addMpsocSupvHandlers(plTask); scheduling::addMpsocSupvHandlers(plTask);
scheduling::scheduleScexDev(plTask); scheduling::scheduleScexDev(plTask);

View File

@ -1,3 +1,4 @@
#include <fsfw/globalfunctions/arrayprinter.h>
#include <linux/payload/PlocMpsocHandler.h> #include <linux/payload/PlocMpsocHandler.h>
#include <linux/payload/plocSupvDefs.h> #include <linux/payload/plocSupvDefs.h>
@ -11,6 +12,7 @@ PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid
CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper, CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper,
Gpio uartIsolatorSwitch, object_id_t supervisorHandler) Gpio uartIsolatorSwitch, object_id_t supervisorHandler)
: DeviceHandlerBase(objectId, uartComIFid, comCookie), : DeviceHandlerBase(objectId, uartComIFid, comCookie),
hkReport(this),
plocMPSoCHelper(plocMPSoCHelper), plocMPSoCHelper(plocMPSoCHelper),
uartIsolatorSwitch(uartIsolatorSwitch), uartIsolatorSwitch(uartIsolatorSwitch),
supervisorHandler(supervisorHandler), supervisorHandler(supervisorHandler),
@ -103,6 +105,7 @@ void PlocMPSoCHandler::performOperationHook() {
ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) { const uint8_t* data, size_t size) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
commandIsPending = true;
switch (actionId) { switch (actionId) {
case mpsoc::SET_UART_TX_TRISTATE: { case mpsoc::SET_UART_TX_TRISTATE: {
uartIsolatorSwitch.pullLow(); uartIsolatorSwitch.pullLow();
@ -151,29 +154,47 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI
} }
void PlocMPSoCHandler::doStartUp() { void PlocMPSoCHandler::doStartUp() {
if (startupState == StartupState::IDLE) {
startupState = StartupState::HW_INIT;
}
if (startupState == StartupState::HW_INIT) {
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
#if not OBSW_MPSOC_JTAG_BOOT == 1 #if not OBSW_MPSOC_JTAG_BOOT == 1
switch (powerState) { switch (powerState) {
case PowerState::OFF: case PowerState::OFF:
commandActionHelper.commandAction(supervisorHandler, supv::START_MPSOC); commandActionHelper.commandAction(supervisorHandler, supv::START_MPSOC);
powerState = PowerState::BOOTING; powerState = PowerState::BOOTING;
break; return;
case PowerState::ON: case PowerState::ON:
setMode(_MODE_TO_ON);
uartIsolatorSwitch.pullHigh(); uartIsolatorSwitch.pullHigh();
startupState = StartupState::WAIT_CYCLES;
break; break;
default: default:
break; return;
} }
#else #else
powerState = PowerState::ON;
setMode(_MODE_TO_ON);
uartIsolatorSwitch.pullHigh(); uartIsolatorSwitch.pullHigh();
startupState = StartupState::WAIT_CYCLES;
#endif /* not MSPOC_JTAG_BOOT == 1 */ #endif /* not MSPOC_JTAG_BOOT == 1 */
#else #else
startupState = StartupState::WAIT_CYCLES;
powerState = PowerState::ON; powerState = PowerState::ON;
setMode(_MODE_TO_ON);
#endif /* XIPHOS_Q7S */ #endif /* XIPHOS_Q7S */
}
// Need to wait, MPSoC still not booted properly, requesting HK without these wait cycles does
// not work, no replies..
if (startupState == StartupState::WAIT_CYCLES) {
waitCycles++;
if (waitCycles >= 8) {
startupState = StartupState::DONE;
waitCycles = 0;
}
}
if (startupState == StartupState::DONE) {
setMode(_MODE_TO_ON);
hkReport.setReportingEnabled(true);
startupState = StartupState::IDLE;
}
} }
void PlocMPSoCHandler::doShutDown() { void PlocMPSoCHandler::doShutDown() {
@ -187,6 +208,7 @@ void PlocMPSoCHandler::doShutDown() {
break; break;
case PowerState::OFF: case PowerState::OFF:
sequenceCount = 0; sequenceCount = 0;
hkReport.setReportingEnabled(false);
setMode(_MODE_POWER_DOWN); setMode(_MODE_POWER_DOWN);
break; break;
default: default:
@ -195,13 +217,20 @@ void PlocMPSoCHandler::doShutDown() {
#else #else
sequenceCount = 0; sequenceCount = 0;
uartIsolatorSwitch.pullLow(); uartIsolatorSwitch.pullLow();
hkReport.setReportingEnabled(false);
setMode(_MODE_POWER_DOWN); setMode(_MODE_POWER_DOWN);
powerState = PowerState::OFF; powerState = PowerState::OFF;
#endif #endif
#endif #endif
startupState = StartupState::IDLE;
} }
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
if (not commandIsPending) {
*id = mpsoc::TC_GET_HK_REPORT;
commandIsPending = true;
return buildCommandFromCommand(*id, nullptr, 0);
}
return NOTHING_TO_SEND; return NOTHING_TO_SEND;
} }
@ -247,6 +276,14 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device
result = prepareTcReplayWriteSequence(commandData, commandDataLen); result = prepareTcReplayWriteSequence(commandData, commandDataLen);
break; break;
} }
case (mpsoc::TC_GET_HK_REPORT): {
result = prepareTcGetHkReport();
break;
}
case (mpsoc::TC_FLASH_GET_DIRECTORY_CONTENT): {
result = prepareTcGetDirContent(commandData, commandDataLen);
break;
}
case (mpsoc::TC_MODE_REPLAY): { case (mpsoc::TC_MODE_REPLAY): {
result = prepareTcModeReplay(); result = prepareTcModeReplay();
break; break;
@ -304,16 +341,20 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(mpsoc::TC_MODE_REPLAY); this->insertInCommandMap(mpsoc::TC_MODE_REPLAY);
this->insertInCommandMap(mpsoc::TC_MODE_IDLE); this->insertInCommandMap(mpsoc::TC_MODE_IDLE);
this->insertInCommandMap(mpsoc::TC_CAM_CMD_SEND); this->insertInCommandMap(mpsoc::TC_CAM_CMD_SEND);
this->insertInCommandMap(mpsoc::TC_GET_HK_REPORT);
this->insertInCommandMap(mpsoc::RELEASE_UART_TX); this->insertInCommandMap(mpsoc::RELEASE_UART_TX);
this->insertInCommandMap(mpsoc::SET_UART_TX_TRISTATE); this->insertInCommandMap(mpsoc::SET_UART_TX_TRISTATE);
this->insertInCommandMap(mpsoc::TC_CAM_TAKE_PIC); this->insertInCommandMap(mpsoc::TC_CAM_TAKE_PIC);
this->insertInCommandMap(mpsoc::TC_FLASH_GET_DIRECTORY_CONTENT);
this->insertInCommandMap(mpsoc::TC_SIMPLEX_SEND_FILE); this->insertInCommandMap(mpsoc::TC_SIMPLEX_SEND_FILE);
this->insertInCommandMap(mpsoc::TC_DOWNLINK_DATA_MODULATE); this->insertInCommandMap(mpsoc::TC_DOWNLINK_DATA_MODULATE);
this->insertInCommandMap(mpsoc::TC_MODE_SNAPSHOT); this->insertInCommandMap(mpsoc::TC_MODE_SNAPSHOT);
this->insertInReplyMap(mpsoc::ACK_REPORT, 3, nullptr, mpsoc::SIZE_ACK_REPORT); this->insertInReplyMap(mpsoc::ACK_REPORT, 3, nullptr, mpsoc::SIZE_ACK_REPORT);
this->insertInReplyMap(mpsoc::EXE_REPORT, 3, nullptr, mpsoc::SIZE_EXE_REPORT); this->insertInReplyMap(mpsoc::EXE_REPORT, 3, nullptr, mpsoc::SIZE_EXE_REPORT);
this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT); this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT);
this->insertInReplyMap(mpsoc::TM_GET_HK_REPORT, 5, nullptr, mpsoc::SIZE_TM_HK_REPORT);
this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, mpsoc::SP_MAX_SIZE); this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, mpsoc::SP_MAX_SIZE);
this->insertInReplyMap(mpsoc::TM_FLASH_DIRECTORY_CONTENT, 2, nullptr, mpsoc::SP_MAX_SIZE);
} }
ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize,
@ -331,6 +372,11 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain
} }
uint16_t apid = spacePacket.getApid(); uint16_t apid = spacePacket.getApid();
auto handleDedicatedReply = [&](DeviceCommandId_t replyId) {
*foundLen = spacePacket.getFullPacketLen();
foundPacketLen = *foundLen;
*foundId = replyId;
};
switch (apid) { switch (apid) {
case (mpsoc::apid::ACK_SUCCESS): case (mpsoc::apid::ACK_SUCCESS):
*foundLen = mpsoc::SIZE_ACK_REPORT; *foundLen = mpsoc::SIZE_ACK_REPORT;
@ -345,10 +391,16 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain
*foundId = mpsoc::TM_MEMORY_READ_REPORT; *foundId = mpsoc::TM_MEMORY_READ_REPORT;
break; break;
case (mpsoc::apid::TM_CAM_CMD_RPT): case (mpsoc::apid::TM_CAM_CMD_RPT):
*foundLen = spacePacket.getFullPacketLen(); handleDedicatedReply(mpsoc::TM_CAM_CMD_RPT);
tmCamCmdRpt.rememberSpacePacketSize = *foundLen;
*foundId = mpsoc::TM_CAM_CMD_RPT;
break; break;
case (mpsoc::apid::TM_HK_GET_REPORT): {
handleDedicatedReply(mpsoc::TM_GET_HK_REPORT);
break;
}
case (mpsoc::apid::TM_FLASH_DIRECTORY_CONTENT): {
handleDedicatedReply(mpsoc::TM_FLASH_DIRECTORY_CONTENT);
break;
}
case (mpsoc::apid::EXE_SUCCESS): case (mpsoc::apid::EXE_SUCCESS):
*foundLen = mpsoc::SIZE_EXE_REPORT; *foundLen = mpsoc::SIZE_EXE_REPORT;
*foundId = mpsoc::EXE_REPORT; *foundId = mpsoc::EXE_REPORT;
@ -358,13 +410,14 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain
*foundId = mpsoc::EXE_REPORT; *foundId = mpsoc::EXE_REPORT;
break; break;
default: { default: {
sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl; sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid APID 0x" << std::hex
<< std::setfill('0') << std::setw(2) << apid << std::dec << std::endl;
*foundLen = remainingSize; *foundLen = remainingSize;
return MPSoCReturnValuesIF::INVALID_APID; return MPSoCReturnValuesIF::INVALID_APID;
} }
} }
uint16_t recvSeqCnt = (*(start + 2) << 8 | *(start + 3)) & PACKET_SEQUENCE_COUNT_MASK; uint16_t recvSeqCnt = ((*(start + 2) << 8) | *(start + 3)) & PACKET_SEQUENCE_COUNT_MASK;
if (recvSeqCnt != sequenceCount) { if (recvSeqCnt != sequenceCount) {
triggerEvent(MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH, sequenceCount, recvSeqCnt); triggerEvent(MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH, sequenceCount, recvSeqCnt);
sequenceCount = recvSeqCnt; sequenceCount = recvSeqCnt;
@ -386,10 +439,26 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const
result = handleMemoryReadReport(packet); result = handleMemoryReadReport(packet);
break; break;
} }
case (mpsoc::TM_GET_HK_REPORT): {
result = handleGetHkReport(packet);
break;
}
case (mpsoc::TM_CAM_CMD_RPT): { case (mpsoc::TM_CAM_CMD_RPT): {
result = handleCamCmdRpt(packet); result = handleCamCmdRpt(packet);
break; break;
} }
case (mpsoc::TM_FLASH_DIRECTORY_CONTENT): {
result = verifyPacket(packet, foundPacketLen);
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
sif::warning << "PLOC MPSoC: Flash directory content reply invalid CRC" << std::endl;
}
/** Send data to commanding queue */
handleDeviceTm(packet + mpsoc::DATA_FIELD_OFFSET,
foundPacketLen - mpsoc::DATA_FIELD_OFFSET - mpsoc::CRC_SIZE,
mpsoc::TM_FLASH_DIRECTORY_CONTENT);
nextReplyId = mpsoc::EXE_REPORT;
return result;
}
case (mpsoc::EXE_REPORT): { case (mpsoc::EXE_REPORT): {
result = handleExecutionReport(packet); result = handleExecutionReport(packet);
break; break;
@ -403,12 +472,51 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const
return result; return result;
} }
void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {} void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {
PoolReadGuard pg(&hkReport);
hkReport.setValidity(false, true);
}
uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 10000; }
ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) { LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(mpsoc::poolid::STATUS, &peStatus);
localDataPoolMap.emplace(mpsoc::poolid::MODE, &peMode);
localDataPoolMap.emplace(mpsoc::poolid::DOWNLINK_PWR_ON, &peDownlinkPwrOn);
localDataPoolMap.emplace(mpsoc::poolid::DOWNLINK_REPLY_ACTIIVE, &peDownlinkReplyActive);
localDataPoolMap.emplace(mpsoc::poolid::DOWNLINK_JESD_SYNC_STATUS, &peDownlinkJesdSyncStatus);
localDataPoolMap.emplace(mpsoc::poolid::DOWNLINK_DAC_STATUS, &peDownlinkDacStatus);
localDataPoolMap.emplace(mpsoc::poolid::CAM_STATUS, &peCameraStatus);
localDataPoolMap.emplace(mpsoc::poolid::CAM_SDI_STATUS, &peCameraSdiStatus);
localDataPoolMap.emplace(mpsoc::poolid::CAM_FPGA_TEMP, &peCameraFpgaTemp);
localDataPoolMap.emplace(mpsoc::poolid::CAM_SOC_TEMP, &peCameraSocTemp);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_TEMP, &peSysmonTemp);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCCINT, &peSysmonVccInt);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCCAUX, &peSysmonVccAux);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCCBRAM, &peSysmonVccBram);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCCPAUX, &peSysmonVccPaux);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCCPINT, &peSysmonVccPint);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCCPDRO, &peSysmonVccPdro);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_MB12V, &peSysmonMb12V);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_MB3V3, &peSysmonMb3V3);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_MB1V8, &peSysmonMb1V8);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC12V, &peSysmonVcc12V);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC5V, &peSysmonVcc5V);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC3V3, &peSysmonVcc3V3);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC3V3VA, &peSysmonVcc3V3VA);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC2V5DDR, &peSysmonVcc2V5DDR);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC1V2DDR, &peSysmonVcc1V2DDR);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC0V9, &peSysmonVcc0V9);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC0V6VTT, &peSysmonVcc0V6VTT);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_SAFE_COTS_CUR, &peSysmonSafeCotsCur);
localDataPoolMap.emplace(mpsoc::poolid::SYSMON_NVM4_XO_CUR, &peSysmonNvm4XoCur);
localDataPoolMap.emplace(mpsoc::poolid::SEM_UNCORRECTABLE_ERRS, &peSemUncorrectableErrs);
localDataPoolMap.emplace(mpsoc::poolid::SEM_CORRECTABLE_ERRS, &peSemCorrectableErrs);
localDataPoolMap.emplace(mpsoc::poolid::SEM_STATUS, &peSemStatus);
localDataPoolMap.emplace(mpsoc::poolid::REBOOT_MPSOC_REQUIRED, &peRebootMpsocRequired);
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(hkReport.getSid(), false, 10.0));
return returnvalue::OK; return returnvalue::OK;
} }
@ -512,6 +620,16 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcGetHkReport() {
mpsoc::TcGetHkReport tcGetHkReport(spParams, sequenceCount);
ReturnValue_t result = tcGetHkReport.buildPacket();
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcGetHkReport.getFullPacketLen());
return returnvalue::OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* commandData, ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
@ -561,9 +679,8 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData,
ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData, ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount); mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount);
result = tcCamTakePic.buildPacket(commandData, commandDataLen); ReturnValue_t result = tcCamTakePic.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
@ -573,9 +690,8 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData,
ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandData, ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount); mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount);
result = tcSimplexSendFile.buildPacket(commandData, commandDataLen); ReturnValue_t result = tcSimplexSendFile.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
@ -583,11 +699,21 @@ ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandD
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocMPSoCHandler::prepareTcGetDirContent(const uint8_t* commandData,
size_t commandDataLen) {
mpsoc::TcGetDirContent tcGetDirContent(spParams, sequenceCount);
ReturnValue_t result = tcGetDirContent.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(tcGetDirContent.getFullPacketLen());
return returnvalue::OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData, ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcDownlinkDataModulate tcDownlinkDataModulate(spParams, sequenceCount); mpsoc::TcDownlinkDataModulate tcDownlinkDataModulate(spParams, sequenceCount);
result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen); ReturnValue_t result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
@ -596,9 +722,8 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* com
} }
ReturnValue_t PlocMPSoCHandler::prepareTcModeSnapshot() { ReturnValue_t PlocMPSoCHandler::prepareTcModeSnapshot() {
ReturnValue_t result = returnvalue::OK;
mpsoc::TcModeSnapshot tcModeSnapshot(spParams, sequenceCount); mpsoc::TcModeSnapshot tcModeSnapshot(spParams, sequenceCount);
result = tcModeSnapshot.buildPacket(); ReturnValue_t result = tcModeSnapshot.buildPacket();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
@ -677,8 +802,23 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
auto cmdDoneHandler = [&](bool success) {
if (normalCmdPending) {
normalCmdPending = false;
}
commandIsPending = false;
auto commandIter = deviceCommandMap.find(getPendingCommand());
if (commandIter != deviceCommandMap.end()) {
commandIter->second.isExecuting = false;
if (commandIter->second.sendReplyTo != MessageQueueIF::NO_QUEUE) {
actionHelper.finish(success, commandIter->second.sendReplyTo, getPendingCommand(), result);
}
}
disableAllReplies();
};
switch (apid) { switch (apid) {
case (mpsoc::apid::EXE_SUCCESS): { case (mpsoc::apid::EXE_SUCCESS): {
cmdDoneHandler(true);
break; break;
} }
case (mpsoc::apid::EXE_FAILURE): { case (mpsoc::apid::EXE_FAILURE): {
@ -694,8 +834,8 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
} }
printStatus(data); printStatus(data);
sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE); sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE);
disableExeReportReply();
result = IGNORE_REPLY_DATA; result = IGNORE_REPLY_DATA;
cmdDoneHandler(false);
break; break;
} }
default: { default: {
@ -718,30 +858,206 @@ ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) {
uint16_t memLen = uint16_t memLen =
*(data + mpsoc::MEM_READ_RPT_LEN_OFFSET) << 8 | *(data + mpsoc::MEM_READ_RPT_LEN_OFFSET + 1); *(data + mpsoc::MEM_READ_RPT_LEN_OFFSET) << 8 | *(data + mpsoc::MEM_READ_RPT_LEN_OFFSET + 1);
/** Send data to commanding queue */ /** Send data to commanding queue */
handleDeviceTM(data + mpsoc::DATA_FIELD_OFFSET, mpsoc::SIZE_MEM_READ_RPT_FIX + memLen * 4, handleDeviceTm(data + mpsoc::DATA_FIELD_OFFSET, mpsoc::SIZE_MEM_READ_RPT_FIX + memLen * 4,
mpsoc::TM_MEMORY_READ_REPORT); mpsoc::TM_MEMORY_READ_REPORT);
nextReplyId = mpsoc::EXE_REPORT; nextReplyId = mpsoc::EXE_REPORT;
return result; return result;
} }
ReturnValue_t PlocMPSoCHandler::handleGetHkReport(const uint8_t* data) {
ReturnValue_t result = verifyPacket(data, foundPacketLen);
if (result != returnvalue::OK) {
return result;
}
SpacePacketReader packetReader(data, foundPacketLen);
const uint8_t* dataStart = data + 6;
PoolReadGuard pg(&hkReport);
size_t deserLen = mpsoc::SIZE_TM_HK_REPORT;
SerializeIF::Endianness endianness = SerializeIF::Endianness::NETWORK;
result = SerializeAdapter::deSerialize(&hkReport.status.value, &dataStart, &deserLen, endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.mode.value, &dataStart, &deserLen, endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.downlinkPwrOn.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.downlinkReplyActive.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.downlinkJesdSyncStatus.value, &dataStart,
&deserLen, endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.downlinkDacStatus.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result =
SerializeAdapter::deSerialize(&hkReport.camStatus.value, &dataStart, &deserLen, endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.camSdiStatus.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result =
SerializeAdapter::deSerialize(&hkReport.camFpgaTemp.value, &dataStart, &deserLen, endianness);
if (result != returnvalue::OK) {
return result;
}
result =
SerializeAdapter::deSerialize(&hkReport.sysmonTemp.value, &dataStart, &deserLen, endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonVccInt.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonVccAux.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonVccBram.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonVccPaux.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonVccPint.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonVccPdro.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result =
SerializeAdapter::deSerialize(&hkReport.sysmonMb12V.value, &dataStart, &deserLen, endianness);
if (result != returnvalue::OK) {
return result;
}
result =
SerializeAdapter::deSerialize(&hkReport.sysmonMb3V3.value, &dataStart, &deserLen, endianness);
if (result != returnvalue::OK) {
return result;
}
result =
SerializeAdapter::deSerialize(&hkReport.sysmonMb1V8.value, &dataStart, &deserLen, endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonVcc12V.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result =
SerializeAdapter::deSerialize(&hkReport.sysmonVcc5V.value, &dataStart, &deserLen, endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonVcc3V3.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonVcc3V3VA.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonVcc2V5DDR.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonVcc1V2DDR.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonVcc0V9.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonVcc0V6VTT.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonSafeCotsCur.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.sysmonNvm4XoCur.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.semUncorrectableErrs.value, &dataStart,
&deserLen, endianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&hkReport.semCorrectableErrs.value, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
result =
SerializeAdapter::deSerialize(&hkReport.semStatus.value, &dataStart, &deserLen, endianness);
if (result != returnvalue::OK) {
return result;
}
// Skip the weird filename
dataStart += 256;
result = SerializeAdapter::deSerialize(&hkReport.rebootMpsocRequired, &dataStart, &deserLen,
endianness);
if (result != returnvalue::OK) {
return result;
}
return returnvalue::OK;
}
ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) { ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = verifyPacket(data, foundPacketLen);
result = verifyPacket(data, tmCamCmdRpt.rememberSpacePacketSize);
if (result == MPSoCReturnValuesIF::CRC_FAILURE) { if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl; sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl;
} }
SpacePacketReader packetReader(data, tmCamCmdRpt.rememberSpacePacketSize); SpacePacketReader packetReader(data, foundPacketLen);
const uint8_t* dataFieldPtr = data + mpsoc::SPACE_PACKET_HEADER_SIZE + sizeof(uint16_t); const uint8_t* dataFieldPtr = data + mpsoc::SPACE_PACKET_HEADER_SIZE + sizeof(uint16_t);
std::string camCmdRptMsg( std::string camCmdRptMsg(reinterpret_cast<const char*>(dataFieldPtr),
reinterpret_cast<const char*>(dataFieldPtr), foundPacketLen - mpsoc::SPACE_PACKET_HEADER_SIZE - sizeof(uint16_t) - 3);
tmCamCmdRpt.rememberSpacePacketSize - mpsoc::SPACE_PACKET_HEADER_SIZE - sizeof(uint16_t) - 3);
#if OBSW_DEBUG_PLOC_MPSOC == 1 #if OBSW_DEBUG_PLOC_MPSOC == 1
uint8_t ackValue = *(packetReader.getFullData() + packetReader.getFullPacketLen() - 2); uint8_t ackValue = *(packetReader.getFullData() + packetReader.getFullPacketLen() - 2);
sif::info << "PlocMPSoCHandler: CamCmdRpt message: " << camCmdRptMsg << std::endl; sif::info << "PlocMPSoCHandler: CamCmdRpt message: " << camCmdRptMsg << std::endl;
sif::info << "PlocMPSoCHandler: CamCmdRpt Ack value: 0x" << std::hex sif::info << "PlocMPSoCHandler: CamCmdRpt Ack value: 0x" << std::hex
<< static_cast<unsigned int>(ackValue) << std::endl; << static_cast<unsigned int>(ackValue) << std::endl;
#endif /* OBSW_DEBUG_PLOC_MPSOC == 1 */ #endif /* OBSW_DEBUG_PLOC_MPSOC == 1 */
handleDeviceTM(packetReader.getPacketData() + sizeof(uint16_t), handleDeviceTm(packetReader.getPacketData() + sizeof(uint16_t),
packetReader.getPacketDataLen() - 1, mpsoc::TM_CAM_CMD_RPT); packetReader.getPacketDataLen() - 1, mpsoc::TM_CAM_CMD_RPT);
return result; return result;
} }
@ -753,6 +1069,16 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
uint8_t enabledReplies = 0; uint8_t enabledReplies = 0;
auto enableThreeReplies = [&](DeviceCommandId_t replyId) {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, replyId);
if (result != returnvalue::OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< mpsoc::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl;
return result;
}
return returnvalue::OK;
};
switch (command->first) { switch (command->first) {
case mpsoc::TC_MEM_WRITE: case mpsoc::TC_MEM_WRITE:
case mpsoc::TC_FLASHDELETE: case mpsoc::TC_FLASHDELETE:
@ -769,24 +1095,30 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
case mpsoc::TC_MODE_SNAPSHOT: case mpsoc::TC_MODE_SNAPSHOT:
enabledReplies = 2; enabledReplies = 2;
break; break;
case mpsoc::TC_MEM_READ: { case mpsoc::TC_GET_HK_REPORT: {
enabledReplies = 3; result = enableThreeReplies(mpsoc::TM_GET_HK_REPORT);
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, if (result != returnvalue::OK) {
mpsoc::TM_MEMORY_READ_REPORT); return result;
}
break;
}
case mpsoc::TC_MEM_READ: {
result = enableThreeReplies(mpsoc::TM_MEMORY_READ_REPORT);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< mpsoc::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl;
return result; return result;
} }
break; break;
} }
case mpsoc::TC_CAM_CMD_SEND: { case mpsoc::TC_CAM_CMD_SEND: {
enabledReplies = 3; result = enableThreeReplies(mpsoc::TM_CAM_CMD_RPT);
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, if (result != returnvalue::OK) {
mpsoc::TM_CAM_CMD_RPT); return result;
}
break;
}
case mpsoc::TC_FLASH_GET_DIRECTORY_CONTENT: {
result = enableThreeReplies(mpsoc::TM_FLASH_DIRECTORY_CONTENT);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< mpsoc::TM_CAM_CMD_RPT << " not in replyMap" << std::endl;
return result; return result;
} }
break; break;
@ -851,12 +1183,21 @@ void PlocMPSoCHandler::setNextReplyId() {
case mpsoc::TC_MEM_READ: case mpsoc::TC_MEM_READ:
nextReplyId = mpsoc::TM_MEMORY_READ_REPORT; nextReplyId = mpsoc::TM_MEMORY_READ_REPORT;
break; break;
case mpsoc::TC_FLASH_GET_DIRECTORY_CONTENT: {
nextReplyId = mpsoc::TM_FLASH_DIRECTORY_CONTENT;
break;
}
case mpsoc::TC_GET_HK_REPORT: {
nextReplyId = mpsoc::TM_GET_HK_REPORT;
break;
}
default: default:
/* If no telemetry is expected the next reply is always the execution report */ /* If no telemetry is expected the next reply is always the execution report */
nextReplyId = mpsoc::EXE_REPORT; nextReplyId = mpsoc::EXE_REPORT;
break; break;
} }
} }
size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
size_t replyLen = 0; size_t replyLen = 0;
@ -881,6 +1222,10 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
// report is not fixed // report is not fixed
replyLen = mpsoc::SP_MAX_SIZE; replyLen = mpsoc::SP_MAX_SIZE;
break; break;
case mpsoc::TM_FLASH_DIRECTORY_CONTENT:
// I think the reply size is not fixed either.
replyLen = mpsoc::SP_MAX_SIZE;
break;
default: { default: {
replyLen = iter->second.replyLen; replyLen = iter->second.replyLen;
break; break;
@ -958,7 +1303,7 @@ void PlocMPSoCHandler::completionFailedReceived(ActionId_t actionId, ReturnValue
handleActionCommandFailure(actionId); handleActionCommandFailure(actionId);
} }
void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, void PlocMPSoCHandler::handleDeviceTm(const uint8_t* data, size_t dataSize,
DeviceCommandId_t replyId) { DeviceCommandId_t replyId) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
@ -996,6 +1341,13 @@ void PlocMPSoCHandler::disableAllReplies() {
DeviceCommandId_t commandId = getPendingCommand(); DeviceCommandId_t commandId = getPendingCommand();
auto disableCommandWithReply = [&](DeviceCommandId_t replyId) {
iter = deviceReplyMap.find(replyId);
info = &(iter->second);
info->delayCycles = 0;
info->active = false;
info->command = deviceCommandMap.end();
};
/* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */
switch (commandId) { switch (commandId) {
case TC_MEM_WRITE: case TC_MEM_WRITE:
@ -1013,19 +1365,19 @@ void PlocMPSoCHandler::disableAllReplies() {
case TC_MODE_SNAPSHOT: case TC_MODE_SNAPSHOT:
break; break;
case TC_MEM_READ: { case TC_MEM_READ: {
iter = deviceReplyMap.find(TM_MEMORY_READ_REPORT); disableCommandWithReply(TM_MEMORY_READ_REPORT);
info = &(iter->second); break;
info->delayCycles = 0; }
info->active = false; case TC_GET_HK_REPORT: {
info->command = deviceCommandMap.end(); disableCommandWithReply(TM_GET_HK_REPORT);
break;
}
case TC_FLASH_GET_DIRECTORY_CONTENT: {
disableCommandWithReply(TM_FLASH_DIRECTORY_CONTENT);
break; break;
} }
case TC_CAM_CMD_SEND: { case TC_CAM_CMD_SEND: {
iter = deviceReplyMap.find(TM_CAM_CMD_RPT); disableCommandWithReply(TM_CAM_CMD_RPT);
info = &(iter->second);
info->delayCycles = 0;
info->active = false;
info->command = deviceCommandMap.end();
break; break;
} }
default: { default: {
@ -1067,12 +1419,12 @@ void PlocMPSoCHandler::disableExeReportReply() {
} }
void PlocMPSoCHandler::printStatus(const uint8_t* data) { void PlocMPSoCHandler::printStatus(const uint8_t* data) {
uint16_t status = *(data + STATUS_OFFSET) << 8 | *(data + STATUS_OFFSET + 1); uint16_t status = (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1);
sif::info << "Verification report status: " << getStatusString(status) << std::endl; sif::info << "Verification report status: " << getStatusString(status) << std::endl;
} }
uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) { uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) {
return *(data + STATUS_OFFSET) << 8 | *(data + STATUS_OFFSET + 1); return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1);
} }
void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) { void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) {
@ -1108,6 +1460,13 @@ void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) {
return; return;
} }
LocalPoolDataSetBase* PlocMPSoCHandler::getDataSetHandle(sid_t sid) {
if (sid == hkReport.getSid()) {
return &hkReport;
}
return nullptr;
}
std::string PlocMPSoCHandler::getStatusString(uint16_t status) { std::string PlocMPSoCHandler::getStatusString(uint16_t status) {
switch (status) { switch (status) {
case (mpsoc::status_code::UNKNOWN_APID): { case (mpsoc::status_code::UNKNOWN_APID): {

View File

@ -77,7 +77,8 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
uint8_t expectedReplies = 1, bool useAlternateId = false, uint8_t expectedReplies = 1, bool useAlternateId = false,
DeviceCommandId_t alternateReplyID = 0) override; DeviceCommandId_t alternateReplyID = 0) override;
size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
virtual ReturnValue_t doSendReadHook() override; ReturnValue_t doSendReadHook() override;
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
private: private:
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER;
@ -105,6 +106,9 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
static const uint8_t STATUS_OFFSET = 10; static const uint8_t STATUS_OFFSET = 10;
mpsoc::HkReport hkReport;
bool normalCmdPending = false;
MessageQueueIF* eventQueue = nullptr; MessageQueueIF* eventQueue = nullptr;
MessageQueueIF* commandActionHelperQueue = nullptr; MessageQueueIF* commandActionHelperQueue = nullptr;
@ -114,6 +118,41 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
SpacePacketCreator creator; SpacePacketCreator creator;
ploc::SpTcParams spParams = ploc::SpTcParams(creator); ploc::SpTcParams spParams = ploc::SpTcParams(creator);
PoolEntry<uint32_t> peStatus = PoolEntry<uint32_t>();
PoolEntry<uint8_t> peMode = PoolEntry<uint8_t>();
PoolEntry<uint8_t> peDownlinkPwrOn = PoolEntry<uint8_t>();
PoolEntry<uint8_t> peDownlinkReplyActive = PoolEntry<uint8_t>();
PoolEntry<uint8_t> peDownlinkJesdSyncStatus = PoolEntry<uint8_t>();
PoolEntry<uint8_t> peDownlinkDacStatus = PoolEntry<uint8_t>();
PoolEntry<uint8_t> peCameraStatus = PoolEntry<uint8_t>();
PoolEntry<uint8_t> peCameraSdiStatus = PoolEntry<uint8_t>();
PoolEntry<float> peCameraFpgaTemp = PoolEntry<float>();
PoolEntry<float> peCameraSocTemp = PoolEntry<float>();
PoolEntry<float> peSysmonTemp = PoolEntry<float>();
PoolEntry<float> peSysmonVccInt = PoolEntry<float>();
PoolEntry<float> peSysmonVccAux = PoolEntry<float>();
PoolEntry<float> peSysmonVccBram = PoolEntry<float>();
PoolEntry<float> peSysmonVccPaux = PoolEntry<float>();
PoolEntry<float> peSysmonVccPint = PoolEntry<float>();
PoolEntry<float> peSysmonVccPdro = PoolEntry<float>();
PoolEntry<float> peSysmonMb12V = PoolEntry<float>();
PoolEntry<float> peSysmonMb3V3 = PoolEntry<float>();
PoolEntry<float> peSysmonMb1V8 = PoolEntry<float>();
PoolEntry<float> peSysmonVcc12V = PoolEntry<float>();
PoolEntry<float> peSysmonVcc5V = PoolEntry<float>();
PoolEntry<float> peSysmonVcc3V3 = PoolEntry<float>();
PoolEntry<float> peSysmonVcc3V3VA = PoolEntry<float>();
PoolEntry<float> peSysmonVcc2V5DDR = PoolEntry<float>();
PoolEntry<float> peSysmonVcc1V2DDR = PoolEntry<float>();
PoolEntry<float> peSysmonVcc0V9 = PoolEntry<float>();
PoolEntry<float> peSysmonVcc0V6VTT = PoolEntry<float>();
PoolEntry<float> peSysmonSafeCotsCur = PoolEntry<float>();
PoolEntry<float> peSysmonNvm4XoCur = PoolEntry<float>();
PoolEntry<uint16_t> peSemUncorrectableErrs = PoolEntry<uint16_t>();
PoolEntry<uint16_t> peSemCorrectableErrs = PoolEntry<uint16_t>();
PoolEntry<uint8_t> peSemStatus = PoolEntry<uint8_t>();
PoolEntry<uint8_t> peRebootMpsocRequired = PoolEntry<uint8_t>();
/** /**
* This variable is used to store the id of the next reply to receive. This is necessary * This variable is used to store the id of the next reply to receive. This is necessary
* because the PLOC sends as reply to each command at least one acknowledgment and execution * because the PLOC sends as reply to each command at least one acknowledgment and execution
@ -130,6 +169,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
// Used to block incoming commands when MPSoC helper class is currently executing a command // Used to block incoming commands when MPSoC helper class is currently executing a command
bool plocMPSoCHelperExecuting = false; bool plocMPSoCHelperExecuting = false;
bool commandIsPending = false;
struct TmMemReadReport { struct TmMemReadReport {
static const uint8_t FIX_SIZE = 14; static const uint8_t FIX_SIZE = 14;
@ -138,19 +178,16 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
TmMemReadReport tmMemReadReport; TmMemReadReport tmMemReadReport;
struct TmCamCmdRpt {
size_t rememberSpacePacketSize = 0;
};
TmCamCmdRpt tmCamCmdRpt;
struct TelemetryBuffer { struct TelemetryBuffer {
uint16_t length = 0; uint16_t length = 0;
uint8_t buffer[mpsoc::SP_MAX_SIZE]; uint8_t buffer[mpsoc::SP_MAX_SIZE];
}; };
size_t foundPacketLen = 0;
TelemetryBuffer tmBuffer; TelemetryBuffer tmBuffer;
uint32_t waitCycles = 0;
enum class StartupState { IDLE, HW_INIT, WAIT_CYCLES, DONE } startupState = StartupState::IDLE;
enum class PowerState { OFF, BOOTING, SHUTDOWN, ON }; enum class PowerState { OFF, BOOTING, SHUTDOWN, ON };
PowerState powerState = PowerState::OFF; PowerState powerState = PowerState::OFF;
@ -167,6 +204,8 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
ReturnValue_t prepareTcReplayStop(); ReturnValue_t prepareTcReplayStop();
ReturnValue_t prepareTcDownlinkPwrOn(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcDownlinkPwrOn(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcDownlinkPwrOff(); ReturnValue_t prepareTcDownlinkPwrOff();
ReturnValue_t prepareTcGetHkReport();
ReturnValue_t prepareTcGetDirContent(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcModeIdle(); ReturnValue_t prepareTcModeIdle();
@ -213,6 +252,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
*/ */
ReturnValue_t handleMemoryReadReport(const uint8_t* data); ReturnValue_t handleMemoryReadReport(const uint8_t* data);
ReturnValue_t handleGetHkReport(const uint8_t* data);
ReturnValue_t handleCamCmdRpt(const uint8_t* data); ReturnValue_t handleCamCmdRpt(const uint8_t* data);
/** /**
@ -231,7 +271,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
* @param dataSize Size of telemetry in bytes. * @param dataSize Size of telemetry in bytes.
* @param replyId Id of the reply. This will be added to the ActionMessage. * @param replyId Id of the reply. This will be added to the ActionMessage.
*/ */
void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); void handleDeviceTm(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId);
/** /**
* @brief In case an acknowledgment failure reply has been received this function disables * @brief In case an acknowledgment failure reply has been received this function disables

View File

@ -1,6 +1,7 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h> #include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <linux/payload/mpsocRetvals.h> #include <linux/payload/mpsocRetvals.h>
#include <mission/payload/plocSpBase.h> #include <mission/payload/plocSpBase.h>
@ -12,6 +13,47 @@
namespace mpsoc { namespace mpsoc {
static constexpr uint32_t HK_SET_ID = 0;
namespace poolid {
enum {
STATUS = 0,
MODE = 1,
DOWNLINK_PWR_ON = 2,
DOWNLINK_REPLY_ACTIIVE = 3,
DOWNLINK_JESD_SYNC_STATUS = 4,
DOWNLINK_DAC_STATUS = 5,
CAM_STATUS = 6,
CAM_SDI_STATUS = 7,
CAM_FPGA_TEMP = 8,
CAM_SOC_TEMP = 9,
SYSMON_TEMP = 10,
SYSMON_VCCINT = 11,
SYSMON_VCCAUX = 12,
SYSMON_VCCBRAM = 13,
SYSMON_VCCPAUX = 14,
SYSMON_VCCPINT = 15,
SYSMON_VCCPDRO = 16,
SYSMON_MB12V = 17,
SYSMON_MB3V3 = 18,
SYSMON_MB1V8 = 19,
SYSMON_VCC12V = 20,
SYSMON_VCC5V = 21,
SYSMON_VCC3V3 = 22,
SYSMON_VCC3V3VA = 23,
SYSMON_VCC2V5DDR = 24,
SYSMON_VCC1V2DDR = 25,
SYSMON_VCC0V9 = 26,
SYSMON_VCC0V6VTT = 27,
SYSMON_SAFE_COTS_CUR = 28,
SYSMON_NVM4_XO_CUR = 29,
SEM_UNCORRECTABLE_ERRS = 30,
SEM_CORRECTABLE_ERRS = 31,
SEM_STATUS = 32,
REBOOT_MPSOC_REQUIRED = 33,
};
}
static const DeviceCommandId_t NONE = 0; static const DeviceCommandId_t NONE = 0;
static const DeviceCommandId_t TC_MEM_WRITE = 1; static const DeviceCommandId_t TC_MEM_WRITE = 1;
static const DeviceCommandId_t TC_MEM_READ = 2; static const DeviceCommandId_t TC_MEM_READ = 2;
@ -37,6 +79,10 @@ static const DeviceCommandId_t TC_CAM_TAKE_PIC = 22;
static const DeviceCommandId_t TC_SIMPLEX_SEND_FILE = 23; static const DeviceCommandId_t TC_SIMPLEX_SEND_FILE = 23;
static const DeviceCommandId_t TC_DOWNLINK_DATA_MODULATE = 24; static const DeviceCommandId_t TC_DOWNLINK_DATA_MODULATE = 24;
static const DeviceCommandId_t TC_MODE_SNAPSHOT = 25; static const DeviceCommandId_t TC_MODE_SNAPSHOT = 25;
static const DeviceCommandId_t TC_GET_HK_REPORT = 26;
static const DeviceCommandId_t TM_GET_HK_REPORT = 27;
static const DeviceCommandId_t TC_FLASH_GET_DIRECTORY_CONTENT = 28;
static const DeviceCommandId_t TM_FLASH_DIRECTORY_CONTENT = 29;
// Will reset the sequence count of the OBSW // Will reset the sequence count of the OBSW
static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50; static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50;
@ -45,6 +91,7 @@ static const uint16_t SIZE_ACK_REPORT = 14;
static const uint16_t SIZE_EXE_REPORT = 14; static const uint16_t SIZE_EXE_REPORT = 14;
static const uint16_t SIZE_TM_MEM_READ_REPORT = 18; static const uint16_t SIZE_TM_MEM_READ_REPORT = 18;
static const uint16_t SIZE_TM_CAM_CMD_RPT = 18; static const uint16_t SIZE_TM_CAM_CMD_RPT = 18;
static constexpr size_t SIZE_TM_HK_REPORT = 369;
/** /**
* SpacePacket apids of PLOC telecommands and telemetry. * SpacePacket apids of PLOC telecommands and telemetry.
@ -60,20 +107,27 @@ static const uint16_t TC_CAM_TAKE_PIC = 0x116;
static const uint16_t TC_FLASHWRITE = 0x117; static const uint16_t TC_FLASHWRITE = 0x117;
static const uint16_t TC_FLASHFOPEN = 0x119; static const uint16_t TC_FLASHFOPEN = 0x119;
static const uint16_t TC_FLASHFCLOSE = 0x11A; static const uint16_t TC_FLASHFCLOSE = 0x11A;
static constexpr uint16_t TC_FLASH_GET_DIRECTORY_CONTENT = 0x11B;
static const uint16_t TC_FLASHDELETE = 0x11C; static const uint16_t TC_FLASHDELETE = 0x11C;
static constexpr uint16_t TC_FLASH_CREATE_DIR = 0x11D;
static const uint16_t TC_MODE_IDLE = 0x11E; static const uint16_t TC_MODE_IDLE = 0x11E;
static const uint16_t TC_MODE_REPLAY = 0x11F; static const uint16_t TC_MODE_REPLAY = 0x11F;
static const uint16_t TC_MODE_SNAPSHOT = 0x120; static const uint16_t TC_MODE_SNAPSHOT = 0x120;
static const uint16_t TC_DOWNLINK_DATA_MODULATE = 0x121; static const uint16_t TC_DOWNLINK_DATA_MODULATE = 0x121;
static constexpr uint16_t TC_HK_GET_REPORT = 0x123;
static const uint16_t TC_DOWNLINK_PWR_OFF = 0x124; static const uint16_t TC_DOWNLINK_PWR_OFF = 0x124;
static const uint16_t TC_CAM_CMD_SEND = 0x12C; static const uint16_t TC_CAM_CMD_SEND = 0x12C;
static constexpr uint16_t TC_FLASH_COPY_FILE = 0x12E;
static const uint16_t TC_SIMPLEX_SEND_FILE = 0x130; static const uint16_t TC_SIMPLEX_SEND_FILE = 0x130;
static const uint16_t TM_MEMORY_READ_REPORT = 0x404;
static const uint16_t ACK_SUCCESS = 0x400; static const uint16_t ACK_SUCCESS = 0x400;
static const uint16_t ACK_FAILURE = 0x401; static const uint16_t ACK_FAILURE = 0x401;
static const uint16_t EXE_SUCCESS = 0x402; static const uint16_t EXE_SUCCESS = 0x402;
static const uint16_t EXE_FAILURE = 0x403; static const uint16_t EXE_FAILURE = 0x403;
static const uint16_t TM_MEMORY_READ_REPORT = 0x404;
static constexpr uint16_t TM_FLASH_DIRECTORY_CONTENT = 0x406;
static const uint16_t TM_CAM_CMD_RPT = 0x407; static const uint16_t TM_CAM_CMD_RPT = 0x407;
static constexpr uint16_t TM_HK_GET_REPORT = 0x408;
} // namespace apid } // namespace apid
/** Offset from first byte in space packet to first byte of data field */ /** Offset from first byte in space packet to first byte of data field */
@ -561,6 +615,30 @@ class TcDownlinkPwrOn : public TcBase {
} }
}; };
class TcGetHkReport : public TcBase {
public:
TcGetHkReport(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_HK_GET_REPORT, sequenceCount) {}
};
class TcGetDirContent : public TcBase {
public:
TcGetDirContent(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_FLASH_GET_DIRECTORY_CONTENT, sequenceCount) {}
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
// Yeah it needs to be 256.. even if the path is shorter.
spParams.setFullPayloadLen(256 + CRC_SIZE);
if (result != returnvalue::OK) {
return result;
}
std::memcpy(payloadStart, commandData, commandDataLen);
payloadStart[255] = '\0';
return result;
}
};
/** /**
* @brief Class to build replay stop space packet. * @brief Class to build replay stop space packet.
*/ */
@ -774,6 +852,66 @@ class TcCamcmdSend : public TcBase {
static const uint8_t CARRIAGE_RETURN = 0xD; static const uint8_t CARRIAGE_RETURN = 0xD;
}; };
class HkReport : public StaticLocalDataSet<36> {
public:
HkReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_SET_ID) {}
HkReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) {}
lp_var_t<uint32_t> status = lp_var_t<uint32_t>(sid.objectId, mpsoc::poolid::STATUS, this);
lp_var_t<uint8_t> mode = lp_var_t<uint8_t>(sid.objectId, mpsoc::poolid::MODE, this);
lp_var_t<uint8_t> downlinkPwrOn =
lp_var_t<uint8_t>(sid.objectId, mpsoc::poolid::DOWNLINK_PWR_ON, this);
lp_var_t<uint8_t> downlinkReplyActive =
lp_var_t<uint8_t>(sid.objectId, mpsoc::poolid::DOWNLINK_REPLY_ACTIIVE, this);
lp_var_t<uint8_t> downlinkJesdSyncStatus =
lp_var_t<uint8_t>(sid.objectId, mpsoc::poolid::DOWNLINK_JESD_SYNC_STATUS, this);
lp_var_t<uint8_t> downlinkDacStatus =
lp_var_t<uint8_t>(sid.objectId, mpsoc::poolid::DOWNLINK_DAC_STATUS, this);
lp_var_t<uint8_t> camStatus = lp_var_t<uint8_t>(sid.objectId, mpsoc::poolid::CAM_STATUS, this);
lp_var_t<uint8_t> camSdiStatus =
lp_var_t<uint8_t>(sid.objectId, mpsoc::poolid::CAM_SDI_STATUS, this);
lp_var_t<float> camFpgaTemp = lp_var_t<float>(sid.objectId, mpsoc::poolid::CAM_FPGA_TEMP, this);
lp_var_t<float> camSocTemp = lp_var_t<float>(sid.objectId, mpsoc::poolid::CAM_SOC_TEMP, this);
lp_var_t<float> sysmonTemp = lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_TEMP, this);
lp_var_t<float> sysmonVccInt = lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_VCCINT, this);
lp_var_t<float> sysmonVccAux = lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_VCCAUX, this);
lp_var_t<float> sysmonVccBram =
lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_VCCBRAM, this);
lp_var_t<float> sysmonVccPaux =
lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_VCCPAUX, this);
lp_var_t<float> sysmonVccPint =
lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_VCCPINT, this);
lp_var_t<float> sysmonVccPdro =
lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_VCCPDRO, this);
lp_var_t<float> sysmonMb12V = lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_MB12V, this);
lp_var_t<float> sysmonMb3V3 = lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_MB3V3, this);
lp_var_t<float> sysmonMb1V8 = lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_MB1V8, this);
lp_var_t<float> sysmonVcc12V = lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_VCC12V, this);
lp_var_t<float> sysmonVcc5V = lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_VCC5V, this);
lp_var_t<float> sysmonVcc3V3 = lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_VCC3V3, this);
lp_var_t<float> sysmonVcc3V3VA =
lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_VCC3V3VA, this);
lp_var_t<float> sysmonVcc2V5DDR =
lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_VCC2V5DDR, this);
lp_var_t<float> sysmonVcc1V2DDR =
lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_VCC1V2DDR, this);
lp_var_t<float> sysmonVcc0V9 = lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_VCC0V9, this);
lp_var_t<float> sysmonVcc0V6VTT =
lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_VCC0V6VTT, this);
lp_var_t<float> sysmonSafeCotsCur =
lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_SAFE_COTS_CUR, this);
lp_var_t<float> sysmonNvm4XoCur =
lp_var_t<float>(sid.objectId, mpsoc::poolid::SYSMON_NVM4_XO_CUR, this);
lp_var_t<uint16_t> semUncorrectableErrs =
lp_var_t<uint16_t>(sid.objectId, mpsoc::poolid::SEM_UNCORRECTABLE_ERRS, this);
lp_var_t<uint16_t> semCorrectableErrs =
lp_var_t<uint16_t>(sid.objectId, mpsoc::poolid::SEM_CORRECTABLE_ERRS, this);
lp_var_t<uint8_t> semStatus = lp_var_t<uint8_t>(sid.objectId, mpsoc::poolid::SEM_STATUS, this);
lp_var_t<uint8_t> rebootMpsocRequired =
lp_var_t<uint8_t>(sid.objectId, mpsoc::poolid::REBOOT_MPSOC_REQUIRED, this);
};
} // namespace mpsoc } // namespace mpsoc
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */ #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */

View File

@ -29,7 +29,7 @@ static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE;
enum Tmp1075PoolIds : lp_id_t { TEMPERATURE_C_TMP1075 }; enum Tmp1075PoolIds : lp_id_t { TEMPERATURE_C_TMP1075 };
class Tmp1075Dataset : public StaticLocalDataSet<sizeof(float)> { class Tmp1075Dataset : public StaticLocalDataSet<2> {
public: public:
Tmp1075Dataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) {} Tmp1075Dataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) {}

2
tmtc

@ -1 +1 @@
Subproject commit f090c3af66d1a0b760344e80053d6e83895e661a Subproject commit 0c1bfc6fd32e66fe0da13bebc4eeb3030ead13a9