WIP adapting PlocMpSoCHandler
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

major PITA, but does compile now, will be back with more patience
This commit is contained in:
2022-07-27 22:03:41 +02:00
parent c8f4f0b03e
commit 24297a6a97
5 changed files with 1004 additions and 882 deletions

View File

@ -5,6 +5,8 @@
#include "fsfw/globalfunctions/CRC.h"
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
//TODO this is work in progress in adapting to new actions
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid,
CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper,
Gpio uartIsolatorSwitch, object_id_t supervisorHandler)
@ -96,16 +98,14 @@ void PlocMPSoCHandler::performOperationHook() {
}
}
ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) {
ReturnValue_t result = RETURN_OK;
switch (actionId) {
case mpsoc::SET_UART_TX_TRISTATE: {
ReturnValue_t PlocMPSoCHandler::executeAction(Action* action) {
switch (PlocMpSoCCommands(action->getId())) {
case PlocMpSoCCommands::SET_UART_TX_TRISTATE: {
uartIsolatorSwitch.pullLow();
return EXECUTION_FINISHED;
break;
}
case mpsoc::RELEASE_UART_TX: {
case PlocMpSoCCommands::RELEASE_UART_TX: {
uartIsolatorSwitch.pullHigh();
return EXECUTION_FINISHED;
break;
@ -118,32 +118,28 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI
return MPSoCReturnValuesIF::MPSOC_HELPER_EXECUTING;
}
switch (actionId) {
case mpsoc::TC_FLASHWRITE: {
if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
return MPSoCReturnValuesIF::FILENAME_TOO_LONG;
}
mpsoc::FlashWritePusCmd flashWritePusCmd;
result = flashWritePusCmd.extractFields(data, size);
if (result != RETURN_OK) {
return result;
}
result = plocMPSoCHelper->startFlashWrite(flashWritePusCmd.getObcFile(),
flashWritePusCmd.getMPSoCFile());
if (result != RETURN_OK) {
return result;
}
plocMPSoCHelperExecuting = true;
return EXECUTION_FINISHED;
switch (PlocMpSoCCommands(action->getId())) {
case PlocMpSoCCommands::TC_FLASHWRITE: {
// refer handling to the handleAction() below
return action->handle();
}
case (mpsoc::OBSW_RESET_SEQ_COUNT): {
case (PlocMpSoCCommands::OBSW_RESET_SEQ_COUNT): {
sequenceCount = 0;
return EXECUTION_FINISHED;
}
default:
break;
}
return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size);
ReturnValue_t result = DeviceHandlerBase::executeAction(action);
if (result == RETURN_OK) {
/**
* Flushing the receive buffer to make sure there are no data left from a faulty reply.
*/
uartComIf->flushUartRxBuffer(comCookie);
}
return result;
}
void PlocMPSoCHandler::doStartUp() {
@ -203,90 +199,31 @@ ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t*
return NOTHING_TO_SEND;
}
ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
switch (deviceCommand) {
case (mpsoc::TC_MEM_WRITE): {
result = prepareTcMemWrite(commandData, commandDataLen);
break;
}
case (mpsoc::TC_MEM_READ): {
result = prepareTcMemRead(commandData, commandDataLen);
break;
}
case (mpsoc::TC_FLASHDELETE): {
result = prepareTcFlashDelete(commandData, commandDataLen);
break;
}
case (mpsoc::TC_REPLAY_START): {
result = prepareTcReplayStart(commandData, commandDataLen);
break;
}
case (mpsoc::TC_REPLAY_STOP): {
result = prepareTcReplayStop();
break;
}
case (mpsoc::TC_DOWNLINK_PWR_ON): {
result = prepareTcDownlinkPwrOn(commandData, commandDataLen);
break;
}
case (mpsoc::TC_DOWNLINK_PWR_OFF): {
result = prepareTcDownlinkPwrOff();
break;
}
case (mpsoc::TC_REPLAY_WRITE_SEQUENCE): {
result = prepareTcReplayWriteSequence(commandData, commandDataLen);
break;
}
case (mpsoc::TC_MODE_REPLAY): {
result = prepareTcModeReplay();
break;
}
case (mpsoc::TC_MODE_IDLE): {
result = prepareTcModeIdle();
break;
}
case (mpsoc::TC_CAM_CMD_SEND): {
result = prepareTcCamCmdSend(commandData, commandDataLen);
break;
}
default:
sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented"
<< std::endl;
result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
break;
}
if (result == RETURN_OK) {
/**
* Flushing the receive buffer to make sure there are no data left from a faulty reply.
*/
uartComIf->flushUartRxBuffer(comCookie);
}
return result;
}
void PlocMPSoCHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(mpsoc::TC_MEM_WRITE);
this->insertInCommandMap(mpsoc::TC_MEM_READ);
this->insertInCommandMap(mpsoc::TC_FLASHDELETE);
this->insertInCommandMap(mpsoc::TC_REPLAY_START);
this->insertInCommandMap(mpsoc::TC_REPLAY_STOP);
this->insertInCommandMap(mpsoc::TC_DOWNLINK_PWR_ON);
this->insertInCommandMap(mpsoc::TC_DOWNLINK_PWR_OFF);
this->insertInCommandMap(mpsoc::TC_REPLAY_WRITE_SEQUENCE);
this->insertInCommandMap(mpsoc::TC_MODE_REPLAY);
this->insertInCommandMap(mpsoc::TC_MODE_IDLE);
this->insertInCommandMap(mpsoc::TC_CAM_CMD_SEND);
this->insertInCommandMap(mpsoc::RELEASE_UART_TX);
this->insertInCommandMap(mpsoc::SET_UART_TX_TRISTATE);
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::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT);
this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, SpacePacket::PACKET_MAX_SIZE);
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_MEM_WRITE));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_MEM_READ));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_FLASHDELETE));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_REPLAY_START));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_REPLAY_STOP));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_DOWNLINK_PWR_ON));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_DOWNLINK_PWR_OFF));
this->insertInCommandMap(
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_REPLAY_WRITE_SEQUENCE));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_MODE_REPLAY));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_MODE_IDLE));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_CAM_CMD_SEND));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::RELEASE_UART_TX));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::SET_UART_TX_TRISTATE));
this->insertInReplyMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT), 3, nullptr,
mpsoc::SIZE_ACK_REPORT);
this->insertInReplyMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT), 3, nullptr,
mpsoc::SIZE_EXE_REPORT);
this->insertInReplyMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT),
2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT);
this->insertInReplyMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT), 2,
nullptr, SpacePacket::PACKET_MAX_SIZE);
}
ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize,
@ -300,28 +237,28 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain
switch (apid) {
case (mpsoc::apid::ACK_SUCCESS):
*foundLen = mpsoc::SIZE_ACK_REPORT;
*foundId = mpsoc::ACK_REPORT;
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT);
break;
case (mpsoc::apid::ACK_FAILURE):
*foundLen = mpsoc::SIZE_ACK_REPORT;
*foundId = mpsoc::ACK_REPORT;
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT);
break;
case (mpsoc::apid::TM_MEMORY_READ_REPORT):
*foundLen = tmMemReadReport.rememberRequestedSize;
*foundId = mpsoc::TM_MEMORY_READ_REPORT;
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT);
break;
case (mpsoc::apid::TM_CAM_CMD_RPT):
*foundLen = spacePacket.getFullSize();
tmCamCmdRpt.rememberSpacePacketSize = *foundLen;
*foundId = mpsoc::TM_CAM_CMD_RPT;
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT);
break;
case (mpsoc::apid::EXE_SUCCESS):
*foundLen = mpsoc::SIZE_EXE_REPORT;
*foundId = mpsoc::EXE_REPORT;
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT);
break;
case (mpsoc::apid::EXE_FAILURE):
*foundLen = mpsoc::SIZE_EXE_REPORT;
*foundId = mpsoc::EXE_REPORT;
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT);
break;
default: {
sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl;
@ -342,20 +279,22 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain
ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
ReturnValue_t result = RETURN_OK;
switch (id) {
case mpsoc::ACK_REPORT: {
PlocMpSoCCommands enumId = PlocMpSoCCommands(id);
switch (enumId) {
case PlocMpSoCCommands::ACK_REPORT: {
result = handleAckReport(packet);
break;
}
case (mpsoc::TM_MEMORY_READ_REPORT): {
case (PlocMpSoCCommands::TM_MEMORY_READ_REPORT): {
result = handleMemoryReadReport(packet);
break;
}
case (mpsoc::TM_CAM_CMD_RPT): {
case (PlocMpSoCCommands::TM_CAM_CMD_RPT): {
result = handleCamCmdRpt(packet);
break;
}
case (mpsoc::EXE_REPORT): {
case (PlocMpSoCCommands::EXE_REPORT): {
result = handleExecutionReport(packet);
break;
}
@ -390,12 +329,11 @@ void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) {
}
}
ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCMemWriteAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcMemWrite tcMemWrite(sequenceCount);
result = tcMemWrite.createPacket(commandData, commandDataLen);
result = tcMemWrite.createPacket(action);
if (result != RETURN_OK) {
sequenceCount--;
return result;
@ -403,13 +341,11 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData,
copyToCommandBuffer(&tcMemWrite);
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCMemReadAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcMemRead tcMemRead(sequenceCount);
result = tcMemRead.createPacket(commandData, commandDataLen);
//result = tcMemRead.createPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
@ -418,17 +354,15 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData,
tmMemReadReport.rememberRequestedSize = tcMemRead.getMemLen() * 4 + TmMemReadReport::FIX_SIZE;
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData,
size_t commandDataLen) {
if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
return MPSoCReturnValuesIF::NAME_TOO_LONG;
}
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCFlashDeleteAction* action) {
// if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
// return MPSoCReturnValuesIF::NAME_TOO_LONG;
// }
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcFlashDelete tcFlashDelete(sequenceCount);
result = tcFlashDelete.createPacket(
std::string(reinterpret_cast<const char*>(commandData), commandDataLen));
//result = tcFlashDelete.createPacket(
// std::string(reinterpret_cast<const char*>(commandData), commandDataLen));
if (result != RETURN_OK) {
sequenceCount--;
return result;
@ -436,13 +370,11 @@ ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData,
copyToCommandBuffer(&tcFlashDelete);
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCReplayStartAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcReplayStart tcReplayStart(sequenceCount);
result = tcReplayStart.createPacket(commandData, commandDataLen);
//result = tcReplayStart.createPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
@ -450,8 +382,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData,
copyToCommandBuffer(&tcReplayStart);
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCReplayStopAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcReplayStop tcReplayStop(sequenceCount);
@ -464,12 +395,11 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() {
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCDownlinkPwrOnAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(sequenceCount);
result = tcDownlinkPwrOn.createPacket(commandData, commandDataLen);
//result = tcDownlinkPwrOn.createPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
@ -477,8 +407,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandDat
copyToCommandBuffer(&tcDownlinkPwrOn);
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCDownlinkPwrOffAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(sequenceCount);
@ -491,12 +420,11 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() {
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCReplayWriteSequenceAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcReplayWriteSeq tcReplayWriteSeq(sequenceCount);
result = tcReplayWriteSeq.createPacket(commandData, commandDataLen);
//result = tcReplayWriteSeq.createPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
@ -505,7 +433,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* comm
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCModeReplayAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcModeReplay tcModeReplay(sequenceCount);
@ -517,11 +445,11 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() {
memcpy(commandBuffer, tcModeReplay.getWholeData(), tcModeReplay.getFullSize());
rawPacket = commandBuffer;
rawPacketLen = tcModeReplay.getFullSize();
nextReplyId = mpsoc::ACK_REPORT;
nextReplyId = PlocMpSoCCommands::ACK_REPORT;
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCModeIdleAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcModeIdle tcModeIdle(sequenceCount);
@ -533,22 +461,52 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() {
memcpy(commandBuffer, tcModeIdle.getWholeData(), tcModeIdle.getFullSize());
rawPacket = commandBuffer;
rawPacketLen = tcModeIdle.getFullSize();
nextReplyId = mpsoc::ACK_REPORT;
nextReplyId = PlocMpSoCCommands::ACK_REPORT;
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCCamCmdSendAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcCamcmdSend tcCamCmdSend(sequenceCount);
result = tcCamCmdSend.createPacket(commandData, commandDataLen);
//result = tcCamCmdSend.createPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
}
copyToCommandBuffer(&tcCamCmdSend);
nextReplyId = mpsoc::TM_CAM_CMD_RPT;
nextReplyId = PlocMpSoCCommands::TM_CAM_CMD_RPT;
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCFlashWriteAction* action) {
ReturnValue_t result;
// if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
// return MPSoCReturnValuesIF::FILENAME_TOO_LONG;
// }
mpsoc::FlashWritePusCmd flashWritePusCmd;
//result = flashWritePusCmd.extractFields(data, size);
if (result != RETURN_OK) {
return result;
}
result = plocMPSoCHelper->startFlashWrite(flashWritePusCmd.getObcFile(),
flashWritePusCmd.getMPSoCFile());
if (result != RETURN_OK) {
return result;
}
plocMPSoCHelperExecuting = true;
return EXECUTION_FINISHED;
}
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCUartTxTristateAction* action) {
// not used
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCReleaseUartTxAction* action) {
// not used
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCObswResetSeqCountAction* action) {
// not used
return RETURN_OK;
}
@ -559,7 +517,7 @@ void PlocMPSoCHandler::copyToCommandBuffer(mpsoc::TcBase* tc) {
memcpy(commandBuffer, tc->getWholeData(), tc->getFullSize());
rawPacket = commandBuffer;
rawPacketLen = tc->getFullSize();
nextReplyId = mpsoc::ACK_REPORT;
nextReplyId = PlocMpSoCCommands::ACK_REPORT;
}
ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
@ -577,10 +535,10 @@ ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
result = verifyPacket(data, mpsoc::SIZE_ACK_REPORT);
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
sif::warning << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl;
nextReplyId = mpsoc::NONE;
nextReplyId = PlocMpSoCCommands::NONE;
replyRawReplyIfnotWiretapped(data, mpsoc::SIZE_ACK_REPORT);
triggerEvent(MPSOC_HANDLER_CRC_FAILURE);
sendFailureReport(mpsoc::ACK_REPORT, MPSoCReturnValuesIF::CRC_FAILURE);
sendFailureReport(PlocMpSoCCommands::ACK_REPORT, MPSoCReturnValuesIF::CRC_FAILURE);
disableAllReplies();
return IGNORE_REPLY_DATA;
}
@ -596,9 +554,9 @@ ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
triggerEvent(ACK_FAILURE, commandId, status);
}
sendFailureReport(mpsoc::ACK_REPORT, status);
sendFailureReport(PlocMpSoCCommands::ACK_REPORT, status);
disableAllReplies();
nextReplyId = mpsoc::NONE;
nextReplyId = PlocMpSoCCommands::NONE;
result = IGNORE_REPLY_DATA;
break;
}
@ -622,7 +580,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
result = verifyPacket(data, mpsoc::SIZE_EXE_REPORT);
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
sif::warning << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl;
nextReplyId = mpsoc::NONE;
nextReplyId = PlocMpSoCCommands::NONE;
return result;
}
@ -644,7 +602,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl;
}
printStatus(data);
sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE);
sendFailureReport(PlocMpSoCCommands::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE);
disableExeReportReply();
result = IGNORE_REPLY_DATA;
break;
@ -655,7 +613,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
break;
}
}
nextReplyId = mpsoc::NONE;
nextReplyId = PlocMpSoCCommands::NONE;
return result;
}
@ -670,8 +628,8 @@ ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) {
*(data + mpsoc::MEM_READ_RPT_LEN_OFFSET) << 8 | *(data + mpsoc::MEM_READ_RPT_LEN_OFFSET + 1);
/** Send data to commanding queue */
handleDeviceTM(data + mpsoc::DATA_FIELD_OFFSET, mpsoc::SIZE_MEM_READ_RPT_FIX + memLen * 4,
mpsoc::TM_MEMORY_READ_REPORT);
nextReplyId = mpsoc::EXE_REPORT;
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT));
nextReplyId = PlocMpSoCCommands::EXE_REPORT;
return result;
}
@ -694,7 +652,7 @@ ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) {
<< static_cast<unsigned int>(ackValue) << std::endl;
#endif /* OBSW_DEBUG_PLOC_MPSOC == 1 */
handleDeviceTM(packet.getPacketData() + sizeof(uint16_t), packet.getPacketDataLength() - 1,
mpsoc::TM_CAM_CMD_RPT);
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT));
return result;
}
@ -705,41 +663,47 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
uint8_t enabledReplies = 0;
switch (command->first) {
case mpsoc::TC_MEM_WRITE:
case mpsoc::TC_FLASHDELETE:
case mpsoc::TC_REPLAY_START:
case mpsoc::TC_REPLAY_STOP:
case mpsoc::TC_DOWNLINK_PWR_ON:
case mpsoc::TC_DOWNLINK_PWR_OFF:
case mpsoc::TC_REPLAY_WRITE_SEQUENCE:
case mpsoc::TC_MODE_REPLAY:
case mpsoc::TC_MODE_IDLE:
PlocMpSoCCommands enumCommand = PlocMpSoCCommands(command->first);
switch (enumCommand) {
case PlocMpSoCCommands::TC_MEM_WRITE:
case PlocMpSoCCommands::TC_FLASHDELETE:
case PlocMpSoCCommands::TC_REPLAY_START:
case PlocMpSoCCommands::TC_REPLAY_STOP:
case PlocMpSoCCommands::TC_DOWNLINK_PWR_ON:
case PlocMpSoCCommands::TC_DOWNLINK_PWR_OFF:
case PlocMpSoCCommands::TC_REPLAY_WRITE_SEQUENCE:
case PlocMpSoCCommands::TC_MODE_REPLAY:
case PlocMpSoCCommands::TC_MODE_IDLE:
enabledReplies = 2;
break;
case mpsoc::TC_MEM_READ: {
case PlocMpSoCCommands::TC_MEM_READ: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
mpsoc::TM_MEMORY_READ_REPORT);
result = DeviceHandlerBase::enableReplyInReplyMap(
command, enabledReplies, true,
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT));
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< mpsoc::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl;
<< static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT)
<< " not in replyMap" << std::endl;
return result;
}
break;
}
case mpsoc::TC_CAM_CMD_SEND: {
case PlocMpSoCCommands::TC_CAM_CMD_SEND: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
mpsoc::TM_CAM_CMD_RPT);
result = DeviceHandlerBase::enableReplyInReplyMap(
command, enabledReplies, true,
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT));
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< mpsoc::TM_CAM_CMD_RPT << " not in replyMap" << std::endl;
<< static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT)
<< " not in replyMap" << std::endl;
return result;
}
break;
}
case mpsoc::OBSW_RESET_SEQ_COUNT:
case PlocMpSoCCommands::OBSW_RESET_SEQ_COUNT:
break;
default:
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl;
@ -750,32 +714,36 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
* Every command causes at least one acknowledgment and one execution report. Therefore both
* replies will be enabled here.
*/
result =
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, mpsoc::ACK_REPORT);
result = DeviceHandlerBase::enableReplyInReplyMap(
command, enabledReplies, true, static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT));
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << mpsoc::ACK_REPORT
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT)
<< " not in replyMap" << std::endl;
}
result =
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, mpsoc::EXE_REPORT);
result = DeviceHandlerBase::enableReplyInReplyMap(
command, enabledReplies, true, static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT));
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << mpsoc::EXE_REPORT
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT)
<< " not in replyMap" << std::endl;
}
switch (command->first) {
case mpsoc::TC_REPLAY_WRITE_SEQUENCE: {
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
switch (enumCommand) {
case PlocMpSoCCommands::TC_REPLAY_WRITE_SEQUENCE: {
DeviceReplyIter iter =
deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT));
// Overwrite delay cycles because replay write sequence command can required up to
// 30 seconds for execution
iter->second.delayCycles = mpsoc::TC_WRITE_SEQ_EXECUTION_DELAY;
break;
}
case mpsoc::TC_DOWNLINK_PWR_ON: {
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
case PlocMpSoCCommands::TC_DOWNLINK_PWR_ON: {
DeviceReplyIter iter =
deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT));
//
iter->second.delayCycles = mpsoc::TC_DOWNLINK_PWR_ON;
iter->second.delayCycles = mpsoc::TC_DOWNLINK_PWR_ON_EXECUTION_DELAY;
break;
}
default:
@ -786,24 +754,24 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
}
void PlocMPSoCHandler::setNextReplyId() {
switch (getPendingCommand()) {
case mpsoc::TC_MEM_READ:
nextReplyId = mpsoc::TM_MEMORY_READ_REPORT;
switch (PlocMpSoCCommands(getPendingCommand())) {
case PlocMpSoCCommands::TC_MEM_READ:
nextReplyId = PlocMpSoCCommands::TM_MEMORY_READ_REPORT;
break;
default:
/* If no telemetry is expected the next reply is always the execution report */
nextReplyId = mpsoc::EXE_REPORT;
nextReplyId = PlocMpSoCCommands::EXE_REPORT;
break;
}
}
size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
size_t replyLen = 0;
if (nextReplyId == mpsoc::NONE) {
if (nextReplyId == PlocMpSoCCommands::NONE) {
return replyLen;
}
DeviceReplyIter iter = deviceReplyMap.find(nextReplyId);
DeviceReplyIter iter = deviceReplyMap.find(static_cast<DeviceCommandId_t>(nextReplyId));
if (iter != deviceReplyMap.end()) {
if (iter->second.delayCycles == 0) {
@ -811,11 +779,11 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
return replyLen;
}
switch (nextReplyId) {
case mpsoc::TM_MEMORY_READ_REPORT: {
case PlocMpSoCCommands::TM_MEMORY_READ_REPORT: {
replyLen = tmMemReadReport.rememberRequestedSize;
break;
}
case mpsoc::TM_CAM_CMD_RPT:
case PlocMpSoCCommands::TM_CAM_CMD_RPT:
// Read acknowledgment, camera and execution report in one go because length of camera
// report is not fixed
replyLen = SpacePacket::PACKET_MAX_SIZE;
@ -827,7 +795,8 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
}
} else {
sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id "
<< std::hex << nextReplyId << " in deviceReplyMap" << std::endl;
<< std::hex << static_cast<DeviceCommandId_t>(nextReplyId) << " in deviceReplyMap"
<< std::endl;
}
return replyLen;
@ -924,31 +893,33 @@ void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize,
}
void PlocMPSoCHandler::disableAllReplies() {
using namespace mpsoc;
DeviceReplyMap::iterator iter;
/* Disable ack reply */
iter = deviceReplyMap.find(ACK_REPORT);
iter = deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT));
DeviceReplyInfo* info = &(iter->second);
info->delayCycles = 0;
info->command = deviceCommandMap.end();
DeviceCommandId_t commandId = getPendingCommand();
PlocMpSoCCommands enumCommand = PlocMpSoCCommands(commandId);
/* If the command expects a telemetry packet the appropriate tm reply will be disabled here */
switch (commandId) {
case TC_MEM_WRITE:
switch (enumCommand) {
case PlocMpSoCCommands::TC_MEM_WRITE:
break;
case TC_MEM_READ: {
iter = deviceReplyMap.find(TM_MEMORY_READ_REPORT);
case PlocMpSoCCommands::TC_MEM_READ: {
iter = deviceReplyMap.find(
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT));
info = &(iter->second);
info->delayCycles = 0;
info->active = false;
info->command = deviceCommandMap.end();
break;
}
case TC_CAM_CMD_SEND: {
iter = deviceReplyMap.find(TM_CAM_CMD_RPT);
case PlocMpSoCCommands::TC_CAM_CMD_SEND: {
iter = deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT));
info = &(iter->second);
info->delayCycles = 0;
info->active = false;
@ -964,11 +935,11 @@ void PlocMPSoCHandler::disableAllReplies() {
/* We always need to disable the execution report reply here */
disableExeReportReply();
nextReplyId = mpsoc::NONE;
nextReplyId = PlocMpSoCCommands::NONE;
}
void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) {
DeviceReplyIter iter = deviceReplyMap.find(replyId);
void PlocMPSoCHandler::sendFailureReport(PlocMpSoCCommands replyId, ReturnValue_t status) {
DeviceReplyIter iter = deviceReplyMap.find(static_cast<DeviceCommandId_t>(replyId));
if (iter == deviceReplyMap.end()) {
sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl;
return;
@ -985,7 +956,8 @@ void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_
}
void PlocMPSoCHandler::disableExeReportReply() {
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
DeviceReplyIter iter =
deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT));
DeviceReplyInfo* info = &(iter->second);
info->delayCycles = 0;
info->command = deviceCommandMap.end();