continue refactoring
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
@ -223,17 +223,17 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
|
||||
spParams.buf = commandBuffer;
|
||||
switch (deviceCommand) {
|
||||
case GET_HK_REPORT: {
|
||||
prepareEmptyCmd(Apids::HK, static_cast<uint8_t>(tc::HkId::GET_REPORT));
|
||||
prepareEmptyCmd(Apid::HK, static_cast<uint8_t>(tc::HkId::GET_REPORT));
|
||||
result = returnvalue::OK;
|
||||
break;
|
||||
}
|
||||
case START_MPSOC: {
|
||||
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::START_MPSOC));
|
||||
prepareEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::START_MPSOC));
|
||||
result = returnvalue::OK;
|
||||
break;
|
||||
}
|
||||
case SHUTDOWN_MPSOC: {
|
||||
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SHUTDOWN_MPSOC));
|
||||
prepareEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SHUTDOWN_MPSOC));
|
||||
result = returnvalue::OK;
|
||||
break;
|
||||
}
|
||||
@ -243,7 +243,7 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
|
||||
break;
|
||||
}
|
||||
case RESET_MPSOC: {
|
||||
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::RESET_MPSOC));
|
||||
prepareEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::RESET_MPSOC));
|
||||
result = returnvalue::OK;
|
||||
break;
|
||||
}
|
||||
@ -267,7 +267,7 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
|
||||
break;
|
||||
}
|
||||
case GET_BOOT_STATUS_REPORT: {
|
||||
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::GET_BOOT_STATUS_REPORT));
|
||||
prepareEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::GET_BOOT_STATUS_REPORT));
|
||||
result = returnvalue::OK;
|
||||
break;
|
||||
}
|
||||
@ -299,8 +299,7 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
|
||||
// break;
|
||||
// }
|
||||
case GET_LATCHUP_STATUS_REPORT: {
|
||||
prepareEmptyCmd(Apids::LATCHUP_MON,
|
||||
static_cast<uint8_t>(tc::LatchupMonId::GET_STATUS_REPORT));
|
||||
prepareEmptyCmd(Apid::LATCHUP_MON, static_cast<uint8_t>(tc::LatchupMonId::GET_STATUS_REPORT));
|
||||
result = returnvalue::OK;
|
||||
break;
|
||||
}
|
||||
@ -381,7 +380,7 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
|
||||
break;
|
||||
}
|
||||
case FACTORY_FLASH: {
|
||||
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::FACTORY_FLASH));
|
||||
prepareEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::FACTORY_FLASH));
|
||||
result = returnvalue::OK;
|
||||
break;
|
||||
}
|
||||
@ -435,7 +434,7 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
|
||||
// break;
|
||||
// }
|
||||
case RESET_PL: {
|
||||
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::RESET_PL));
|
||||
prepareEmptyCmd(Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::RESET_PL));
|
||||
result = returnvalue::OK;
|
||||
break;
|
||||
}
|
||||
@ -654,73 +653,66 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
|
||||
ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
||||
DeviceCommandId_t* foundId, size_t* foundLen) {
|
||||
using namespace supv;
|
||||
if (nextReplyId == FIRST_MRAM_DUMP) {
|
||||
*foundId = FIRST_MRAM_DUMP;
|
||||
return parseMramPackets(start, remainingSize, foundLen);
|
||||
} else if (nextReplyId == CONSECUTIVE_MRAM_DUMP) {
|
||||
*foundId = CONSECUTIVE_MRAM_DUMP;
|
||||
return parseMramPackets(start, remainingSize, foundLen);
|
||||
}
|
||||
// TODO: Is this still required?
|
||||
// if (nextReplyId == FIRST_MRAM_DUMP) {
|
||||
// *foundId = FIRST_MRAM_DUMP;
|
||||
// return parseMramPackets(start, remainingSize, foundLen);
|
||||
// } else if (nextReplyId == CONSECUTIVE_MRAM_DUMP) {
|
||||
// *foundId = CONSECUTIVE_MRAM_DUMP;
|
||||
// return parseMramPackets(start, remainingSize, foundLen);
|
||||
// }
|
||||
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
|
||||
uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK;
|
||||
tmReader.setData(start, remainingSize);
|
||||
uint16_t apid = tmReader.getApid(); //(*(start) << 8 | *(start + 1)) & APID_MASK;
|
||||
|
||||
switch (apid) {
|
||||
case (APID_ACK_SUCCESS):
|
||||
*foundLen = SIZE_ACK_REPORT;
|
||||
*foundId = ACK_REPORT;
|
||||
case (Apid::TMTC_MAN): {
|
||||
switch (tmReader.getServiceId()) {
|
||||
case (static_cast<uint8_t>(supv::tm::TmtcId::ACK)):
|
||||
case (static_cast<uint8_t>(supv::tm::TmtcId::NAK)): {
|
||||
*foundLen = SIZE_ACK_REPORT;
|
||||
*foundId = ACK_REPORT;
|
||||
return OK;
|
||||
}
|
||||
case (static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK)):
|
||||
case (static_cast<uint8_t>(supv::tm::TmtcId::EXEC_NAK)): {
|
||||
*foundLen = SIZE_EXE_REPORT;
|
||||
*foundId = EXE_REPORT;
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (APID_ACK_FAILURE):
|
||||
*foundLen = SIZE_ACK_REPORT;
|
||||
*foundId = ACK_REPORT;
|
||||
}
|
||||
case (Apid::HK): {
|
||||
if (tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::HkId::REPORT)) {
|
||||
*foundLen = SIZE_HK_REPORT;
|
||||
*foundId = HK_REPORT;
|
||||
return OK;
|
||||
} else if (tmReader.getServiceId() == static_cast<uint8_t>(supv::tm::HkId::HARDFAULTS)) {
|
||||
handleBadApidServiceCombination(SUPV_UNINIMPLEMENTED_TM, apid, tmReader.getServiceId());
|
||||
return INVALID_DATA;
|
||||
}
|
||||
break;
|
||||
case (APID_HK_REPORT):
|
||||
*foundLen = SIZE_HK_REPORT;
|
||||
*foundId = HK_REPORT;
|
||||
}
|
||||
case (Apid::BOOT_MAN): {
|
||||
if (tmReader.getServiceId() ==
|
||||
static_cast<uint8_t>(supv::tm::BootManId::BOOT_STATUS_REPORT)) {
|
||||
*foundLen = SIZE_BOOT_STATUS_REPORT;
|
||||
*foundId = BOOT_STATUS_REPORT;
|
||||
return OK;
|
||||
}
|
||||
break;
|
||||
case (APID_BOOT_STATUS_REPORT):
|
||||
*foundLen = SIZE_BOOT_STATUS_REPORT;
|
||||
*foundId = BOOT_STATUS_REPORT;
|
||||
break;
|
||||
case (APID_LATCHUP_STATUS_REPORT):
|
||||
*foundLen = SIZE_LATCHUP_STATUS_REPORT;
|
||||
*foundId = LATCHUP_REPORT;
|
||||
break;
|
||||
case (APID_DATA_LOGGER_DATA):
|
||||
*foundLen = SIZE_LOGGING_REPORT;
|
||||
*foundId = LOGGING_REPORT;
|
||||
break;
|
||||
case (APID_ADC_REPORT):
|
||||
*foundLen = SIZE_ADC_REPORT;
|
||||
*foundId = ADC_REPORT;
|
||||
break;
|
||||
case (APID_EXE_SUCCESS):
|
||||
*foundLen = SIZE_EXE_REPORT;
|
||||
*foundId = EXE_REPORT;
|
||||
break;
|
||||
case (APID_EXE_FAILURE):
|
||||
*foundLen = SIZE_EXE_REPORT;
|
||||
*foundId = EXE_REPORT;
|
||||
break;
|
||||
default: {
|
||||
sif::debug << "PlocSupervisorHandler::scanForReply: Reply has invalid apid" << std::endl;
|
||||
*foundLen = remainingSize;
|
||||
return result::INVALID_APID;
|
||||
}
|
||||
case (Apid::MEM_MAN): {
|
||||
if (tmReader.getServiceId() ==
|
||||
static_cast<uint8_t>(supv::tm::MemManId::UPDATE_STATUS_REPORT)) {
|
||||
// TODO: I think this will be handled by the uart manager
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::getSwitches(const uint8_t** switches,
|
||||
uint8_t* numberOfSwitches) {
|
||||
if (powerSwitch == power::NO_SWITCH) {
|
||||
return DeviceHandlerBase::NO_SWITCH;
|
||||
}
|
||||
*numberOfSwitches = 1;
|
||||
*switches = &powerSwitch;
|
||||
return returnvalue::OK;
|
||||
handleBadApidServiceCombination(SUPV_UNKNOWN_TM, apid, tmReader.getServiceId());
|
||||
*foundLen = remainingSize;
|
||||
return INVALID_DATA;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
@ -771,6 +763,16 @@ ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::getSwitches(const uint8_t** switches,
|
||||
uint8_t* numberOfSwitches) {
|
||||
if (powerSwitch == power::NO_SWITCH) {
|
||||
return DeviceHandlerBase::NO_SWITCH;
|
||||
}
|
||||
*numberOfSwitches = 1;
|
||||
*switches = &powerSwitch;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::setNormalDatapoolEntriesInvalid() {}
|
||||
|
||||
uint32_t PlocSupervisorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
|
||||
@ -932,56 +934,57 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
|
||||
// TODO: Fix
|
||||
// AcknowledgmentReport ack(data, SIZE_ACK_REPORT);
|
||||
// result = ack.checkSize();
|
||||
// if (result != returnvalue::OK) {
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// AcknowledgmentReport ack(data, SIZE_ACK_REPORT);
|
||||
// result = ack.checkSize();
|
||||
// if (result != returnvalue::OK) {
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// result = ack.checkCrc();
|
||||
// if (result != returnvalue::OK) {
|
||||
// sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl;
|
||||
// nextReplyId = supv::NONE;
|
||||
// replyRawReplyIfnotWiretapped(data, supv::SIZE_ACK_REPORT);
|
||||
// triggerEvent(SUPV_CRC_FAILURE_EVENT);
|
||||
// sendFailureReport(supv::ACK_REPORT, SupvReturnValuesIF::CRC_FAILURE);
|
||||
// disableAllReplies();
|
||||
// return returnvalue::OK;
|
||||
// }
|
||||
// result = ack.checkCrc();
|
||||
// if (result != returnvalue::OK) {
|
||||
// sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl;
|
||||
// nextReplyId = supv::NONE;
|
||||
// replyRawReplyIfnotWiretapped(data, supv::SIZE_ACK_REPORT);
|
||||
// triggerEvent(SUPV_CRC_FAILURE_EVENT);
|
||||
// sendFailureReport(supv::ACK_REPORT, SupvReturnValuesIF::CRC_FAILURE);
|
||||
// disableAllReplies();
|
||||
// return returnvalue::OK;
|
||||
// }
|
||||
//
|
||||
// result = ack.checkApid();
|
||||
// result = ack.checkApid();
|
||||
//
|
||||
// switch (result) {
|
||||
// case SupvReturnValuesIF::RECEIVED_ACK_FAILURE: {
|
||||
// DeviceCommandId_t commandId = getPendingCommand();
|
||||
// if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
||||
// triggerEvent(SUPV_ACK_FAILURE, commandId, static_cast<uint32_t>(ack.getStatusCode()));
|
||||
// }
|
||||
// printAckFailureInfo(ack.getStatusCode(), commandId);
|
||||
// sendFailureReport(supv::ACK_REPORT, SupvReturnValuesIF::RECEIVED_ACK_FAILURE);
|
||||
// disableAllReplies();
|
||||
// nextReplyId = supv::NONE;
|
||||
// result = IGNORE_REPLY_DATA;
|
||||
// break;
|
||||
// }
|
||||
// case returnvalue::OK: {
|
||||
// setNextReplyId();
|
||||
// break;
|
||||
// }
|
||||
// case SupvReturnValuesIF::INVALID_APID:
|
||||
// sif::warning << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report"
|
||||
// << std::endl;
|
||||
// sendFailureReport(supv::ACK_REPORT, result);
|
||||
// disableAllReplies();
|
||||
// nextReplyId = supv::NONE;
|
||||
// result = IGNORE_REPLY_DATA;
|
||||
// break;
|
||||
// default: {
|
||||
// sif::error << "PlocSupervisorHandler::handleAckReport: APID parsing failed" << std::endl;
|
||||
// result = returnvalue::FAILED;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// switch (result) {
|
||||
// case SupvReturnValuesIF::RECEIVED_ACK_FAILURE: {
|
||||
// DeviceCommandId_t commandId = getPendingCommand();
|
||||
// if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
||||
// triggerEvent(SUPV_ACK_FAILURE, commandId, static_cast<uint32_t>(ack.getStatusCode()));
|
||||
// }
|
||||
// printAckFailureInfo(ack.getStatusCode(), commandId);
|
||||
// sendFailureReport(supv::ACK_REPORT, SupvReturnValuesIF::RECEIVED_ACK_FAILURE);
|
||||
// disableAllReplies();
|
||||
// nextReplyId = supv::NONE;
|
||||
// result = IGNORE_REPLY_DATA;
|
||||
// break;
|
||||
// }
|
||||
// case returnvalue::OK: {
|
||||
// setNextReplyId();
|
||||
// break;
|
||||
// }
|
||||
// case SupvReturnValuesIF::INVALID_APID:
|
||||
// sif::warning << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report"
|
||||
// << std::endl;
|
||||
// sendFailureReport(supv::ACK_REPORT, result);
|
||||
// disableAllReplies();
|
||||
// nextReplyId = supv::NONE;
|
||||
// result = IGNORE_REPLY_DATA;
|
||||
// break;
|
||||
// default: {
|
||||
// sif::error << "PlocSupervisorHandler::handleAckReport: APID parsing failed" << std::endl;
|
||||
// result = returnvalue::FAILED;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1806,39 +1809,40 @@ void PlocSupervisorHandler::disableExeReportReply() {
|
||||
info->command->second.expectedReplies = 1;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t* packet, size_t remainingSize,
|
||||
size_t* foundLen) {
|
||||
ReturnValue_t result = IGNORE_FULL_PACKET;
|
||||
uint16_t packetLen = 0;
|
||||
*foundLen = 0;
|
||||
|
||||
for (size_t idx = 0; idx < remainingSize; idx++) {
|
||||
std::memcpy(spacePacketBuffer + bufferTop, packet + idx, 1);
|
||||
bufferTop += 1;
|
||||
*foundLen += 1;
|
||||
if (bufferTop >= ccsds::HEADER_LEN) {
|
||||
packetLen = readSpacePacketLength(spacePacketBuffer);
|
||||
}
|
||||
|
||||
if (bufferTop == ccsds::HEADER_LEN + packetLen + 1) {
|
||||
packetInBuffer = true;
|
||||
bufferTop = 0;
|
||||
return checkMramPacketApid();
|
||||
}
|
||||
|
||||
if (bufferTop == supv::MAX_PACKET_SIZE) {
|
||||
*foundLen = remainingSize;
|
||||
disableAllReplies();
|
||||
bufferTop = 0;
|
||||
sif::info << "PlocSupervisorHandler::parseMramPackets: Can not find MRAM packet in space "
|
||||
"packet buffer"
|
||||
<< std::endl;
|
||||
return result::MRAM_PACKET_PARSING_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
// ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t* packet, size_t
|
||||
// remainingSize,
|
||||
// size_t* foundLen) {
|
||||
// ReturnValue_t result = IGNORE_FULL_PACKET;
|
||||
// uint16_t packetLen = 0;
|
||||
// *foundLen = 0;
|
||||
//
|
||||
// for (size_t idx = 0; idx < remainingSize; idx++) {
|
||||
// std::memcpy(spacePacketBuffer + bufferTop, packet + idx, 1);
|
||||
// bufferTop += 1;
|
||||
// *foundLen += 1;
|
||||
// if (bufferTop >= ccsds::HEADER_LEN) {
|
||||
// packetLen = readSpacePacketLength(spacePacketBuffer);
|
||||
// }
|
||||
//
|
||||
// if (bufferTop == ccsds::HEADER_LEN + packetLen + 1) {
|
||||
// packetInBuffer = true;
|
||||
// bufferTop = 0;
|
||||
// return checkMramPacketApid();
|
||||
// }
|
||||
//
|
||||
// if (bufferTop == supv::MAX_PACKET_SIZE) {
|
||||
// *foundLen = remainingSize;
|
||||
// disableAllReplies();
|
||||
// bufferTop = 0;
|
||||
// sif::info << "PlocSupervisorHandler::parseMramPackets: Can not find MRAM packet in space "
|
||||
// "packet buffer"
|
||||
// << std::endl;
|
||||
// return result::MRAM_PACKET_PARSING_FAILURE;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket(DeviceCommandId_t id) {
|
||||
ReturnValue_t result = returnvalue::FAILED;
|
||||
@ -1916,13 +1920,14 @@ void PlocSupervisorHandler::increaseExpectedMramReplies(DeviceCommandId_t id) {
|
||||
return;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::checkMramPacketApid() {
|
||||
uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & supv::APID_MASK;
|
||||
if (apid != supv::APID_MRAM_DUMP_TM) {
|
||||
return result::NO_MRAM_PACKET;
|
||||
}
|
||||
return APERIODIC_REPLY;
|
||||
}
|
||||
// ReturnValue_t PlocSupervisorHandler::checkMramPacketApid() {
|
||||
// uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & supv::APID_MASK;
|
||||
// TODO: Fix
|
||||
// if (apid != supv::APID_MRAM_DUMP_TM) {
|
||||
// return result::NO_MRAM_PACKET;
|
||||
// }
|
||||
// return APERIODIC_REPLY;
|
||||
//}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::handleMramDumpFile(DeviceCommandId_t id) {
|
||||
#ifdef XIPHOS_Q7S
|
||||
@ -2164,6 +2169,19 @@ void PlocSupervisorHandler::handleExecutionFailureReport(uint16_t statusCode) {
|
||||
disableExeReportReply();
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::handleBadApidServiceCombination(Event event, unsigned int apid,
|
||||
unsigned int serviceId) {
|
||||
const char* printString = "";
|
||||
if (event == SUPV_UNKNOWN_TM) {
|
||||
printString = "Unknown";
|
||||
} else if (event == SUPV_UNINIMPLEMENTED_TM) {
|
||||
printString = "Unimplemented";
|
||||
}
|
||||
triggerEvent(event, apid, tmReader.getServiceId());
|
||||
sif::error << printString << " APID service combination 0x" << std::setw(2) << std::setfill('0')
|
||||
<< std::hex << apid << ", " << std::setw(2) << serviceId << std::endl;
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::printAckFailureInfo(uint16_t statusCode, DeviceCommandId_t commandId) {
|
||||
sif::warning << "PlocSupervisorHandler: Received Ack failure report with status code: 0x"
|
||||
<< std::hex << statusCode << std::endl;
|
||||
|
Reference in New Issue
Block a user