Merge branch 'ploc_mpsoc_dir_content_report' into ploc_mpsoc_read_file
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good

This commit is contained in:
Robin Müller 2023-05-04 10:49:35 +02:00
commit 51f70897a8
Signed by: muellerr
GPG Key ID: A649FB78196E3849
4 changed files with 99 additions and 23 deletions

View File

@ -28,12 +28,15 @@ will consitute of a breaking change warranting a new major release:
- Do not construct and schedule broken TMP1075 device anymore. - Do not construct and schedule broken TMP1075 device anymore.
- Do not track payload modes in system mode tables. - Do not track payload modes in system mode tables.
- ACS modes derived from system modes. - ACS modes derived from system modes.
- Add support for MPSoC HK packet.
- Dynamically enable and disable HK packets for MPSoC on `ON` and `OFF` commands.
## Added ## Added
- Add the remaining system modes. - Add the remaining system modes.
- 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.
- PLOC MPSoC device handler: Read file support.
## Fixed ## Fixed

View File

@ -262,6 +262,10 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device
result = prepareTcGetHkReport(); result = prepareTcGetHkReport();
break; 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;
@ -325,14 +329,16 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() {
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, 2, nullptr, 0); this->insertInReplyMap(mpsoc::TM_GET_HK_REPORT, 2, 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, 0);
} }
ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize,
@ -350,6 +356,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;
@ -364,14 +375,14 @@ 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);
foundPacketLen = *foundLen;
*foundId = mpsoc::TM_CAM_CMD_RPT;
break; break;
case (mpsoc::apid::TM_HK_GET_REPORT): { case (mpsoc::apid::TM_HK_GET_REPORT): {
*foundLen = spacePacket.getFullPacketLen(); handleDedicatedReply(mpsoc::TM_GET_HK_REPORT);
foundPacketLen = *foundLen; break;
*foundId = mpsoc::TM_GET_HK_REPORT; }
case (mpsoc::apid::TM_FLASH_DIRECTORY_CONTENT): {
handleDedicatedReply(mpsoc::TM_FLASH_DIRECTORY_CONTENT);
break; break;
} }
case (mpsoc::apid::EXE_SUCCESS): case (mpsoc::apid::EXE_SUCCESS):
@ -419,6 +430,18 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const
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;
@ -432,7 +455,10 @@ 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 5000; }
@ -635,9 +661,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;
} }
@ -647,9 +672,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;
} }
@ -657,11 +681,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;
} }
@ -670,9 +704,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;
} }
@ -792,7 +825,7 @@ 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;
@ -991,7 +1024,7 @@ ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) {
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;
} }
@ -1050,6 +1083,13 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
} }
break; break;
} }
case mpsoc::TC_FLASH_GET_DIRECTORY_CONTENT: {
result = enableThreeReplies(mpsoc::TM_FLASH_DIRECTORY_CONTENT);
if (result != returnvalue::OK) {
return result;
}
break;
}
case mpsoc::OBSW_RESET_SEQ_COUNT: case mpsoc::OBSW_RESET_SEQ_COUNT:
break; break;
default: default:
@ -1116,6 +1156,7 @@ void PlocMPSoCHandler::setNextReplyId() {
break; break;
} }
} }
size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
size_t replyLen = 0; size_t replyLen = 0;
@ -1140,6 +1181,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;
@ -1217,7 +1262,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;
@ -1286,6 +1331,10 @@ void PlocMPSoCHandler::disableAllReplies() {
disableCommandWithReply(TM_GET_HK_REPORT); disableCommandWithReply(TM_GET_HK_REPORT);
break; break;
} }
case TC_FLASH_GET_DIRECTORY_CONTENT: {
disableCommandWithReply(TM_FLASH_DIRECTORY_CONTENT);
break;
}
case TC_CAM_CMD_SEND: { case TC_CAM_CMD_SEND: {
disableCommandWithReply(TM_CAM_CMD_RPT); disableCommandWithReply(TM_CAM_CMD_RPT);
break; break;

View File

@ -201,6 +201,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
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 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();
@ -266,7 +267,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

@ -81,6 +81,8 @@ 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 TC_GET_HK_REPORT = 26;
static const DeviceCommandId_t TM_GET_HK_REPORT = 27; 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;
static constexpr DeviceCommandId_t TC_FLASH_READ_FULL_FILE = 30; static constexpr DeviceCommandId_t TC_FLASH_READ_FULL_FILE = 30;
// Will reset the sequence count of the OBSW // Will reset the sequence count of the OBSW
@ -107,15 +109,17 @@ static constexpr uint16_t TC_FLASHWRITE = 0x117;
static constexpr uint16_t TC_FLASHREAD = 0x118; static constexpr uint16_t TC_FLASHREAD = 0x118;
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 constexpr uint16_t TC_HK_GET_REPORT = 0x123;
static constexpr uint16_t TM_HK_GET_REPORT = 0x408;
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 ACK_SUCCESS = 0x400; static const uint16_t ACK_SUCCESS = 0x400;
static const uint16_t ACK_FAILURE = 0x401; static const uint16_t ACK_FAILURE = 0x401;
@ -123,7 +127,9 @@ 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 const uint16_t TM_MEMORY_READ_REPORT = 0x404;
static const uint16_t TM_FLASH_READ_REPORT = 0x405; static const uint16_t TM_FLASH_READ_REPORT = 0x405;
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 */
@ -661,6 +667,23 @@ class TcGetHkReport : public TcBase {
: TcBase(params, apid::TC_HK_GET_REPORT, 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;
spParams.setFullPayloadLen(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE);
if (result != returnvalue::OK) {
return result;
}
std::memcpy(payloadStart, commandData, commandDataLen);
*(payloadStart + commandDataLen) = NULL_TERMINATOR;
return result;
}
};
/** /**
* @brief Class to build replay stop space packet. * @brief Class to build replay stop space packet.
*/ */