this should do the job
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
parent
63e7b928cf
commit
2015839d60
2
fsfw
2
fsfw
@ -1 +1 @@
|
||||
Subproject commit f307a86d9a972d29ee82234a415bf60a7ce4b6bc
|
||||
Subproject commit b8ae64606061e593c573d94c70de18e99ce2a00a
|
@ -1,11 +1,15 @@
|
||||
#include "FreshMpsocHandler.h"
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "eive/objects.h"
|
||||
#include "fsfw/action/CommandActionHelper.h"
|
||||
#include "fsfw/datapool/PoolReadGuard.h"
|
||||
#include "fsfw/devicehandlers/FreshDeviceHandlerBase.h"
|
||||
#include "fsfw/ipc/MessageQueueIF.h"
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "linux/payload/MpsocCommunication.h"
|
||||
#include "linux/payload/plocMpsocHelpers.h"
|
||||
#include "linux/payload/plocSupvDefs.h"
|
||||
|
||||
FreshMpsocHandler::FreshMpsocHandler(DhbConfig cfg, MpsocCommunication& comInterface,
|
||||
@ -16,7 +20,8 @@ FreshMpsocHandler::FreshMpsocHandler(DhbConfig cfg, MpsocCommunication& comInter
|
||||
specialComHelper(specialComHelper),
|
||||
commandActionHelper(this),
|
||||
uartIsolatorSwitch(uartIsolatorSwitch),
|
||||
hkReport(this) {
|
||||
hkReport(this),
|
||||
supervisorHandler(supervisorHandler) {
|
||||
commandActionHelperQueue = QueueFactory::instance()->createMessageQueue(10);
|
||||
eventQueue = QueueFactory::instance()->createMessageQueue(10);
|
||||
spParams.maxSize = sizeof(commandBuffer);
|
||||
@ -276,9 +281,33 @@ ReturnValue_t FreshMpsocHandler::performDeviceOperationPreQueueHandling(uint8_t
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void FreshMpsocHandler::handleTransitionToOn() {}
|
||||
void FreshMpsocHandler::handleTransitionToOn() {
|
||||
if (startupState == StartupState::IDLE) {
|
||||
startupState = StartupState::HW_INIT;
|
||||
}
|
||||
if (startupState == StartupState::HW_INIT) {
|
||||
if (handleHwStartup()) {
|
||||
startupState = StartupState::DONE;
|
||||
}
|
||||
}
|
||||
if (startupState == StartupState::DONE) {
|
||||
setMode(MODE_ON);
|
||||
hkReport.setReportingEnabled(true);
|
||||
powerState = PowerState::IDLE;
|
||||
startupState = StartupState::IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
void FreshMpsocHandler::handleTransitionToOff() {}
|
||||
void FreshMpsocHandler::handleTransitionToOff() {
|
||||
if (handleHwShutdown()) {
|
||||
hkReport.setReportingEnabled(false);
|
||||
setMode(MODE_OFF);
|
||||
// commandIsPending = false;
|
||||
// sequenceCount = 0;
|
||||
powerState = PowerState::IDLE;
|
||||
startupState = StartupState::IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
MessageQueueIF* FreshMpsocHandler::getCommandQueuePtr() { return commandActionHelperQueue; }
|
||||
|
||||
@ -580,8 +609,6 @@ ReturnValue_t FreshMpsocHandler::prepareTcCamCmdSend(const uint8_t* commandData,
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcCamCmdSend);
|
||||
// TODO: Send this synchronously now..
|
||||
// nextReplyId = mpsoc::TM_CAM_CMD_RPT;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
@ -636,15 +663,11 @@ ReturnValue_t FreshMpsocHandler::prepareTcModeSnapshot() {
|
||||
}
|
||||
|
||||
ReturnValue_t FreshMpsocHandler::finishTcPrep(mpsoc::TcBase& tcBase) {
|
||||
// TODO: Fix this, similar to how it was done for the SUPV. might be able to implement this
|
||||
// in a simpler way, only allowing strictly sequential commanding.
|
||||
// nextReplyId = mpsoc::ACK_REPORT;
|
||||
ReturnValue_t result = tcBase.finishPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
// rawPacket = commandBuffer;
|
||||
// rawPacketLen = tcBase.getFullPacketLen();
|
||||
// TODO: We should find a way so this works with the old implementation.
|
||||
commandSequenceCount++;
|
||||
|
||||
if (DEBUG_MPSOC_COMMUNICATION) {
|
||||
@ -671,10 +694,10 @@ void FreshMpsocHandler::handleEvent(EventMessage* eventMessage) {
|
||||
}
|
||||
|
||||
void FreshMpsocHandler::cmdDoneHandler(bool success, ReturnValue_t result) {
|
||||
activeCmdInfo.pending = false;
|
||||
if (activeCmdInfo.commandedBy != MessageQueueIF::NO_QUEUE) {
|
||||
actionHelper.finish(success, activeCmdInfo.commandedBy, activeCmdInfo.pendingCmd, result);
|
||||
}
|
||||
activeCmdInfo.reset();
|
||||
}
|
||||
|
||||
ReturnValue_t FreshMpsocHandler::handleDeviceReply() {
|
||||
@ -697,59 +720,28 @@ ReturnValue_t FreshMpsocHandler::handleDeviceReply() {
|
||||
}
|
||||
uint16_t apid = replyReader.getApid();
|
||||
|
||||
// auto handleDedicatedReply = [&](DeviceCommandId_t replyId) {
|
||||
//*foundLen = spacePacket.getFullPacketLen();
|
||||
// foundPacketLen = *foundLen;
|
||||
// *foundId = replyId;
|
||||
// };
|
||||
switch (apid) {
|
||||
case (mpsoc::apid::ACK_SUCCESS):
|
||||
// *foundLen = mpsoc::SIZE_ACK_REPORT;
|
||||
//*foundId = mpsoc::ACK_REPORT;
|
||||
result = handleAckReport();
|
||||
|
||||
break;
|
||||
case (mpsoc::apid::ACK_FAILURE):
|
||||
// *foundLen = mpsoc::SIZE_ACK_REPORT;
|
||||
//*foundId = mpsoc::ACK_REPORT;
|
||||
break;
|
||||
case (mpsoc::apid::TM_MEMORY_READ_REPORT):
|
||||
// *foundLen = tmMemReadReport.rememberRequestedSize;
|
||||
//*foundId = mpsoc::TM_MEMORY_READ_REPORT;
|
||||
result = handleMemoryReadReport(packet);
|
||||
result = reportReplyData();
|
||||
break;
|
||||
case (mpsoc::apid::TM_CAM_CMD_RPT):
|
||||
// handleDedicatedReply(mpsoc::TM_CAM_CMD_RPT);
|
||||
result = handleCamCmdRpt(packet);
|
||||
result = reportReplyData();
|
||||
break;
|
||||
case (mpsoc::apid::TM_HK_GET_REPORT): {
|
||||
// handleDedicatedReply(mpsoc::TM_GET_HK_REPORT);
|
||||
result = handleGetHkReport(packet);
|
||||
result = handleGetHkReport();
|
||||
break;
|
||||
}
|
||||
case (mpsoc::apid::TM_FLASH_DIRECTORY_CONTENT): {
|
||||
// handleDedicatedReply(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;
|
||||
result = reportReplyData();
|
||||
break;
|
||||
}
|
||||
case (mpsoc::apid::EXE_SUCCESS):
|
||||
//*foundLen = mpsoc::SIZE_EXE_REPORT;
|
||||
//*foundId = mpsoc::EXE_REPORT;
|
||||
result = handleExecutionReport(packet);
|
||||
break;
|
||||
case (mpsoc::apid::EXE_FAILURE):
|
||||
//*foundLen = mpsoc::SIZE_EXE_REPORT;
|
||||
//*foundId = mpsoc::EXE_REPORT;
|
||||
result = handleExecutionReport(packet);
|
||||
result = handleExecutionReport();
|
||||
break;
|
||||
default: {
|
||||
sif::debug << "FreshMpsocHandler:: Reply has invalid APID 0x" << std::hex << std::setfill('0')
|
||||
@ -759,7 +751,7 @@ ReturnValue_t FreshMpsocHandler::handleDeviceReply() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Rework sequence count handling.
|
||||
// TODO: We should implement some way so this can also be used with the former implementation.
|
||||
uint16_t sequenceCount = replyReader.getSequenceCount();
|
||||
if (sequenceCount != lastReplySequenceCount + 1) {
|
||||
// TODO: Trigger event for possible missing reply packet to inform operator.
|
||||
@ -769,43 +761,54 @@ ReturnValue_t FreshMpsocHandler::handleDeviceReply() {
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t FreshMpsocHandler::handleAckReport() {
|
||||
ReturnValue_t FreshMpsocHandler::handleExecutionReport() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
auto& replyReader = comInterface.getSpReader();
|
||||
|
||||
// result = verifyPacket(data, mpsoc::SIZE_ACK_REPORT);
|
||||
// if (result == mpsoc::CRC_FAILURE) {
|
||||
// sif::warning << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl;
|
||||
// nextReplyId = mpsoc::NONE;
|
||||
// replyRawReplyIfnotWiretapped(data, mpsoc::SIZE_ACK_REPORT);
|
||||
// triggerEvent(MPSOC_HANDLER_CRC_FAILURE);
|
||||
// sendFailureReport(mpsoc::ACK_REPORT, MPSoCReturnValuesIF::CRC_FAILURE);
|
||||
// disableAllReplies();
|
||||
// return IGNORE_REPLY_DATA;
|
||||
//}
|
||||
switch (replyReader.getApid()) {
|
||||
case (mpsoc::apid::EXE_SUCCESS): {
|
||||
cmdDoneHandler(true, result);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::apid::EXE_FAILURE): {
|
||||
DeviceCommandId_t commandId = activeCmdInfo.pendingCmd;
|
||||
if (commandId == DeviceHandlerIF::NO_COMMAND_ID) {
|
||||
sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl;
|
||||
}
|
||||
uint16_t status = mpsoc::getStatusFromRawData(replyReader.getFullData());
|
||||
sif::warning << "MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl;
|
||||
triggerEvent(mpsoc::EXE_FAILURE, commandId, status);
|
||||
sendFailureReport(mpsoc::EXE_REPORT, mpsoc::RECEIVED_EXE_FAILURE);
|
||||
cmdDoneHandler(false, mpsoc::RECEIVED_EXE_FAILURE);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sif::warning << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl;
|
||||
result = returnvalue::FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
|
||||
ReturnValue_t FreshMpsocHandler::handleAckReport() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
auto& replyReader = comInterface.getSpReader();
|
||||
|
||||
switch (replyReader.getApid()) {
|
||||
case mpsoc::apid::ACK_FAILURE: {
|
||||
// DeviceCommandId_t commandId = getPendingCommand();
|
||||
uint16_t status = mpsoc::getStatusFromRawData(replyReader.getFullData());
|
||||
sif::warning << "MPSoC ACK Failure: " << mpsoc::getStatusString(status) << std::endl;
|
||||
if (activeCmdInfo.pendingCmd != DeviceHandlerIF::NO_COMMAND_ID) {
|
||||
triggerEvent(ACK_FAILURE, commandId, status);
|
||||
}
|
||||
sendFailureReport(mpsoc::ACK_REPORT, status);
|
||||
disableAllReplies();
|
||||
nextReplyId = mpsoc::NONE;
|
||||
result = IGNORE_REPLY_DATA;
|
||||
triggerEvent(mpsoc::ACK_FAILURE, activeCmdInfo.pendingCmd, status);
|
||||
cmdDoneHandler(false, status);
|
||||
break;
|
||||
}
|
||||
case mpsoc::apid::ACK_SUCCESS: {
|
||||
setNextReplyId();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sif::debug << "PlocMPSoCHandler::handleAckReport: Invalid APID in Ack report" << std::endl;
|
||||
sif::error << "FreshMpsocHandler::handleAckReport: Invalid APID in ACK report" << std::endl;
|
||||
result = returnvalue::FAILED;
|
||||
break;
|
||||
}
|
||||
@ -813,3 +816,293 @@ ReturnValue_t FreshMpsocHandler::handleAckReport() {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t FreshMpsocHandler::getParameter(uint8_t domainId, uint8_t uniqueId,
|
||||
ParameterWrapper* parameterWrapper,
|
||||
const ParameterWrapper* newValues,
|
||||
uint16_t startAtIndex) {
|
||||
if (uniqueId == mpsoc::ParamId::SKIP_SUPV_ON_COMMANDING) {
|
||||
uint8_t value = 0;
|
||||
newValues->getElement(&value);
|
||||
if (value > 1) {
|
||||
return HasParametersIF::INVALID_VALUE;
|
||||
}
|
||||
parameterWrapper->set(skipSupvCommandingToOn);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
return FreshDeviceHandlerBase::getParameter(domainId, uniqueId, parameterWrapper, newValues,
|
||||
startAtIndex);
|
||||
}
|
||||
|
||||
ReturnValue_t FreshMpsocHandler::reportReplyData() {
|
||||
auto& replyReader = comInterface.getSpReader();
|
||||
if (activeCmdInfo.commandedBy != MessageQueueIF::NO_QUEUE) {
|
||||
return actionHelper.reportData(
|
||||
activeCmdInfo.commandedBy, activeCmdInfo.pendingCmd,
|
||||
replyReader.getFullData() + mpsoc::DATA_FIELD_OFFSET,
|
||||
replyReader.getFullPacketLen() - mpsoc::DATA_FIELD_OFFSET - mpsoc::CRC_SIZE);
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t FreshMpsocHandler::handleGetHkReport() {
|
||||
auto& spReader = comInterface.getSpReader();
|
||||
const uint8_t* dataStart = spReader.getFullData() + 6;
|
||||
PoolReadGuard pg(&hkReport);
|
||||
size_t deserLen = mpsoc::SIZE_TM_HK_REPORT;
|
||||
SerializeIF::Endianness endianness = SerializeIF::Endianness::NETWORK;
|
||||
ReturnValue_t 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;
|
||||
}
|
||||
hkReport.setValidity(true, true);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
bool FreshMpsocHandler::handleHwStartup() {
|
||||
#if OBSW_MPSOC_JTAG_BOOT == 1
|
||||
uartIsolatorSwitch.pullHigh();
|
||||
startupState = StartupState::WAIT_CYCLES;
|
||||
return true;
|
||||
#endif
|
||||
if (powerState == PowerState::IDLE) {
|
||||
if (skipSupvCommandingToOn) {
|
||||
powerState = PowerState::DONE;
|
||||
} else {
|
||||
if (supv::SUPV_ON) {
|
||||
commandActionHelper.commandAction(supervisorHandler, supv::START_MPSOC);
|
||||
supvTransitionCd.resetTimer();
|
||||
powerState = PowerState::PENDING_STARTUP;
|
||||
} else {
|
||||
triggerEvent(mpsoc::SUPV_NOT_ON, 1);
|
||||
// Set back to OFF for now, failing the transition.
|
||||
setMode(MODE_OFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (powerState == PowerState::SUPV_FAILED) {
|
||||
setMode(MODE_OFF);
|
||||
powerState = PowerState::IDLE;
|
||||
return false;
|
||||
}
|
||||
if (powerState == PowerState::PENDING_STARTUP) {
|
||||
if (supvTransitionCd.hasTimedOut()) {
|
||||
// Process with transition nonetheless..
|
||||
triggerEvent(mpsoc::SUPV_REPLY_TIMEOUT);
|
||||
powerState = PowerState::DONE;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (powerState == PowerState::DONE) {
|
||||
if (mpsocBootTransitionCd.hasTimedOut()) {
|
||||
// Wait a bit for the MPSoC to fully boot.
|
||||
uartIsolatorSwitch.pullHigh();
|
||||
powerState = PowerState::IDLE;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FreshMpsocHandler::handleHwShutdown() {
|
||||
stopSpecialComHelper();
|
||||
uartIsolatorSwitch.pullLow();
|
||||
#if OBSW_MPSOC_JTAG_BOOT == 1
|
||||
powerState = PowerState::DONE;
|
||||
return true;
|
||||
#endif
|
||||
|
||||
if (powerState == PowerState::IDLE) {
|
||||
if (supv::SUPV_ON) {
|
||||
commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC);
|
||||
supvTransitionCd.resetTimer();
|
||||
powerState = PowerState::PENDING_SHUTDOWN;
|
||||
} else {
|
||||
triggerEvent(mpsoc::SUPV_NOT_ON, 0);
|
||||
powerState = PowerState::DONE;
|
||||
}
|
||||
}
|
||||
if (powerState == PowerState::PENDING_SHUTDOWN) {
|
||||
if (supvTransitionCd.hasTimedOut()) {
|
||||
powerState = PowerState::DONE;
|
||||
// Process with transition nonetheless..
|
||||
triggerEvent(mpsoc::SUPV_REPLY_TIMEOUT);
|
||||
return true;
|
||||
} else {
|
||||
// Wait till power state is OFF.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void FreshMpsocHandler::stopSpecialComHelper() {
|
||||
if (specialComHelper != nullptr) {
|
||||
specialComHelper->stopProcess();
|
||||
}
|
||||
specialComHelperExecuting = false;
|
||||
}
|
||||
|
@ -50,8 +50,9 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI
|
||||
MessageQueueIF* commandActionHelperQueue = nullptr;
|
||||
CommandActionHelper commandActionHelper;
|
||||
Gpio uartIsolatorSwitch;
|
||||
|
||||
mpsoc::HkReport hkReport;
|
||||
object_id_t supervisorHandler;
|
||||
|
||||
Countdown mpsocBootTransitionCd = Countdown(6500);
|
||||
Countdown supvTransitionCd = Countdown(3000);
|
||||
|
||||
@ -127,6 +128,7 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI
|
||||
|
||||
TmMemReadReport tmMemReadReport;
|
||||
uint32_t lastReplySequenceCount = 0;
|
||||
uint8_t skipSupvCommandingToOn = false;
|
||||
|
||||
// HK manager abstract functions.
|
||||
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
@ -156,6 +158,8 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI
|
||||
void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override;
|
||||
void completionSuccessfulReceived(ActionId_t actionId) override;
|
||||
void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override;
|
||||
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, ParameterWrapper* parameterWrapper,
|
||||
const ParameterWrapper* newValues, uint16_t startAtIndex) override;
|
||||
|
||||
void handleActionCommandFailure(ActionId_t actionId);
|
||||
ReturnValue_t executeRegularCmd(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
@ -186,4 +190,12 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI
|
||||
void cmdDoneHandler(bool success, ReturnValue_t result);
|
||||
ReturnValue_t handleDeviceReply();
|
||||
ReturnValue_t handleAckReport();
|
||||
ReturnValue_t handleExecutionReport();
|
||||
void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status);
|
||||
ReturnValue_t reportReplyData();
|
||||
ReturnValue_t handleGetHkReport();
|
||||
bool handleHwStartup();
|
||||
bool handleHwShutdown();
|
||||
|
||||
void stopSpecialComHelper();
|
||||
};
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "fsfw/returnvalues/returnvalue.h"
|
||||
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
|
||||
#include "fsfw/tmtcpacket/ccsds/header.h"
|
||||
#include "linux/payload/plocMpsocHelpers.h"
|
||||
#include "unistd.h"
|
||||
|
||||
MpsocCommunication::MpsocCommunication(object_id_t objectId, SerialConfig cfg)
|
||||
@ -45,6 +46,7 @@ ReturnValue_t MpsocCommunication::parseAndRetrieveNextPacket() {
|
||||
// Possibly invalid packet. We can not even trust the detected packet length.
|
||||
// Just clear the whole read buffer as well.
|
||||
readRingBuf.clear();
|
||||
triggerEvent(mpsoc::CRC_FAILURE);
|
||||
return CRC_CHECK_FAILED;
|
||||
}
|
||||
readRingBuf.deleteData(spReader.getFullPacketLen());
|
||||
|
@ -141,7 +141,7 @@ ReturnValue_t PlocMpsocHandler::executeAction(ActionId_t actionId, MessageQueueI
|
||||
}
|
||||
|
||||
if (specialComHelperExecuting) {
|
||||
return MPSoCReturnValuesIF::MPSOC_HELPER_EXECUTING;
|
||||
return mpsoc::MPSOC_HELPER_EXECUTING;
|
||||
}
|
||||
|
||||
switch (actionId) {
|
||||
@ -410,7 +410,7 @@ ReturnValue_t PlocMpsocHandler::scanForReply(const uint8_t* start, size_t remain
|
||||
sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid APID 0x" << std::hex
|
||||
<< std::setfill('0') << std::setw(2) << apid << std::dec << std::endl;
|
||||
*foundLen = remainingSize;
|
||||
return MPSoCReturnValuesIF::INVALID_APID;
|
||||
return mpsoc::INVALID_APID;
|
||||
}
|
||||
}
|
||||
|
||||
@ -447,7 +447,7 @@ ReturnValue_t PlocMpsocHandler::interpretDeviceReply(DeviceCommandId_t id, const
|
||||
}
|
||||
case (mpsoc::TM_FLASH_DIRECTORY_CONTENT): {
|
||||
result = verifyPacket(packet, foundPacketLen);
|
||||
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
||||
if (result == mpsoc::CRC_FAILURE) {
|
||||
sif::warning << "PLOC MPSoC: Flash directory content reply invalid CRC" << std::endl;
|
||||
}
|
||||
/** Send data to commanding queue */
|
||||
@ -559,7 +559,7 @@ ReturnValue_t PlocMpsocHandler::prepareTcMemRead(const uint8_t* commandData,
|
||||
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;
|
||||
return mpsoc::NAME_TOO_LONG;
|
||||
}
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
mpsoc::TcFlashDelete tcFlashDelete(spParams, sequenceCount);
|
||||
@ -720,7 +720,7 @@ ReturnValue_t PlocMpsocHandler::finishTcPrep(mpsoc::TcBase& tcBase) {
|
||||
|
||||
ReturnValue_t PlocMpsocHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
|
||||
if (CRC::crc16ccitt(start, foundLen) != 0) {
|
||||
return MPSoCReturnValuesIF::CRC_FAILURE;
|
||||
return mpsoc::CRC_FAILURE;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
@ -729,12 +729,12 @@ ReturnValue_t PlocMpsocHandler::handleAckReport(const uint8_t* data) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
|
||||
result = verifyPacket(data, mpsoc::SIZE_ACK_REPORT);
|
||||
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
||||
if (result == mpsoc::CRC_FAILURE) {
|
||||
sif::warning << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl;
|
||||
nextReplyId = mpsoc::NONE;
|
||||
replyRawReplyIfnotWiretapped(data, mpsoc::SIZE_ACK_REPORT);
|
||||
triggerEvent(MPSOC_HANDLER_CRC_FAILURE);
|
||||
sendFailureReport(mpsoc::ACK_REPORT, MPSoCReturnValuesIF::CRC_FAILURE);
|
||||
sendFailureReport(mpsoc::ACK_REPORT, mpsoc::CRC_FAILURE);
|
||||
disableAllReplies();
|
||||
return IGNORE_REPLY_DATA;
|
||||
}
|
||||
@ -773,7 +773,7 @@ ReturnValue_t PlocMpsocHandler::handleExecutionReport(const uint8_t* data) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
|
||||
result = verifyPacket(data, mpsoc::SIZE_EXE_REPORT);
|
||||
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
||||
if (result == mpsoc::CRC_FAILURE) {
|
||||
sif::warning << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl;
|
||||
nextReplyId = mpsoc::NONE;
|
||||
return result;
|
||||
@ -794,9 +794,9 @@ ReturnValue_t PlocMpsocHandler::handleExecutionReport(const uint8_t* data) {
|
||||
uint16_t status = mpsoc::getStatusFromRawData(data);
|
||||
sif::warning << "MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl;
|
||||
triggerEvent(EXE_FAILURE, commandId, status);
|
||||
sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE);
|
||||
sendFailureReport(mpsoc::EXE_REPORT, mpsoc::RECEIVED_EXE_FAILURE);
|
||||
result = IGNORE_REPLY_DATA;
|
||||
cmdDoneHandler(false, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE);
|
||||
cmdDoneHandler(false, mpsoc::RECEIVED_EXE_FAILURE);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -812,7 +812,7 @@ ReturnValue_t PlocMpsocHandler::handleExecutionReport(const uint8_t* data) {
|
||||
ReturnValue_t PlocMpsocHandler::handleMemoryReadReport(const uint8_t* data) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
result = verifyPacket(data, tmMemReadReport.rememberRequestedSize);
|
||||
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
||||
if (result == mpsoc::CRC_FAILURE) {
|
||||
sif::warning << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc"
|
||||
<< std::endl;
|
||||
}
|
||||
@ -1006,7 +1006,7 @@ ReturnValue_t PlocMpsocHandler::handleGetHkReport(const uint8_t* data) {
|
||||
|
||||
ReturnValue_t PlocMpsocHandler::handleCamCmdRpt(const uint8_t* data) {
|
||||
ReturnValue_t result = verifyPacket(data, foundPacketLen);
|
||||
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
||||
if (result == mpsoc::CRC_FAILURE) {
|
||||
sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl;
|
||||
}
|
||||
SpacePacketReader packetReader(data, foundPacketLen);
|
||||
|
Loading…
Reference in New Issue
Block a user