diff --git a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h index 8b93515d..ee16339d 100644 --- a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -29,6 +29,9 @@ static const DeviceCommandId_t TC_MODE_REPLAY = 16; static const DeviceCommandId_t TC_CAM_CMD_SEND = 17; static const DeviceCommandId_t TC_MODE_IDLE = 18; static const DeviceCommandId_t TM_CAM_CMD_RPT = 19; +static const DeviceCommandId_t SET_UART_TX_TRISTATE = 20; +static const DeviceCommandId_t RELEASE_UART_TX = 21; + // Will reset the sequence count of the OBSW static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50; diff --git a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h index 8fc98bc0..23f3f758 100644 --- a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -1304,8 +1304,8 @@ class VerificationReport : public TmPacket { uint16_t refApid = 0; size_t size = 0; uint8_t* refApidPtr = this->getPacketData(); - ReturnValue_t result = SerializeAdapter::deSerialize(&refApid, refApidPtr, &size, - SerializeIF::Endianness::BIG); + ReturnValue_t result = + SerializeAdapter::deSerialize(&refApid, refApidPtr, &size, SerializeIF::Endianness::BIG); if (result != HasReturnvaluesIF::RETURN_OK) { sif::debug << "ExecutionReport: Failed to deserialize reference APID field" << std::endl; return result; @@ -1378,8 +1378,8 @@ class AcknowledgmentReport : public VerificationReport { break; } case StatusCode::DEFAULT_NAK: { - sif::warning << "Supervisor acknowledgment report status: Default code for nak" << - std::endl; + sif::warning << "Supervisor acknowledgment report status: Default code for nak" + << std::endl; break; } case StatusCode::ROUTE_PACKET: { @@ -1456,20 +1456,21 @@ class ExecutionReport : public VerificationReport { MPSOC_BOOT_FAILED = 0x106, SP_NOT_AVAILABLE = 0x200, SP_DATA_INSUFFICIENT = 0x201, - MPSOC_NOT_IN_RESET = 0x202, - FLASH_INIT_FAILED = 0x203, - FLASH_ERASE_FAILED = 0x204, - FLASH_WRITE_FAILED = 0x205, - FLASH_VERIFY_FAILED = 0x206, - CANNOT_ACCESS_TM = 0x207, - CANNOT_SEND_TM = 0x208, + SP_MEMORY_ID_INVALID = 0x202, + MPSOC_NOT_IN_RESET = 0x203, + FLASH_INIT_FAILED = 0x204, + FLASH_ERASE_FAILED = 0x205, + FLASH_WRITE_FAILED = 0x206, + FLASH_VERIFY_FAILED = 0x207, + CANNOT_ACCESS_TM = 0x208, + CANNOT_SEND_TM = 0x209, PG_LOW = 0x300, PG_5V_LOW = 0x301, PG_0V85_LOW = 0x302, PG_1V8_LOW = 0x303, PG_MISC_LOW = 0x304, PG_3V3_LOW = 0x305, - PG__MB_VAIO_LOW = 0x306, + PG_MB_VAIO_LOW = 0x306, PG_MB_MPSOCIO_LOW = 0x307 }; @@ -1581,26 +1582,95 @@ class ExecutionReport : public VerificationReport { break; } case StatusCode::OUT_OF_HEAP_MEMORY: { - sif::warning - << "Supervisor execution report status: Out of heap memory" << std::endl; + sif::warning << "Supervisor execution report status: Out of heap memory" << std::endl; break; } case StatusCode::INVALID_STATE_TRANSITION: { - sif::warning - << "Supervisor execution report status: Invalid state transition" << std::endl; + sif::warning << "Supervisor execution report status: Invalid state transition" << std::endl; break; } case StatusCode::MPSOC_BOOT_FAILED: { - sif::warning - << "Supervisor execution report status: MPSoC boot failed" << std::endl; + sif::warning << "Supervisor execution report status: MPSoC boot failed" << std::endl; + break; + } + case StatusCode::SP_NOT_AVAILABLE: { + sif::warning << "Supervisor execution report status: SP not available" << std::endl; + break; + } + case StatusCode::SP_DATA_INSUFFICIENT: { + sif::warning << "Supervisor execution report status: SP data insufficient" << std::endl; + break; + } + case StatusCode::SP_MEMORY_ID_INVALID: { + sif::warning << "Supervisor execution report status: SP data insufficient" << std::endl; + break; + } + case StatusCode::MPSOC_NOT_IN_RESET: { + sif::warning << "Supervisor execution report status: MPSoC not in reset" << std::endl; + break; + } + case StatusCode::FLASH_INIT_FAILED: { + sif::warning << "Supervisor execution report status: Flash init failed" << std::endl; + break; + } + case StatusCode::FLASH_ERASE_FAILED: { + sif::warning << "Supervisor execution report status: Flash erase failed" << std::endl; + break; + } + case StatusCode::FLASH_WRITE_FAILED: { + sif::warning << "Supervisor execution report status: Flash write failed" << std::endl; + break; + } + case StatusCode::FLASH_VERIFY_FAILED: { + sif::warning << "Supervisor execution report status: Flash verify failed" << std::endl; + break; + } + case StatusCode::CANNOT_ACCESS_TM: { + sif::warning << "Supervisor execution report status: Can not access tm" << std::endl; + break; + } + case StatusCode::CANNOT_SEND_TM: { + sif::warning << "Supervisor execution report status: Can not access tm" << std::endl; + break; + } + case StatusCode::PG_LOW: { + sif::warning << "Supervisor execution report status: PG low" << std::endl; + break; + } + case StatusCode::PG_5V_LOW: { + sif::warning << "Supervisor execution report status: PG 5V low" << std::endl; + break; + } + case StatusCode::PG_0V85_LOW: { + sif::warning << "Supervisor execution report status: PG 0V85 low" << std::endl; + break; + } + case StatusCode::PG_1V8_LOW: { + sif::warning << "Supervisor execution report status: PG 1V8 low" << std::endl; + break; + } + case StatusCode::PG_MISC_LOW: { + sif::warning << "Supervisor execution report status: PG misc low" << std::endl; + break; + } + case StatusCode::PG_3V3_LOW: { + sif::warning << "Supervisor execution report status: PG 3V3 low" << std::endl; + break; + } + case StatusCode::PG_MB_VAIO_LOW: { + sif::warning << "Supervisor execution report status: PG mb vaio low" << std::endl; + break; + } + case StatusCode::PG_MB_MPSOCIO_LOW: { + sif::warning << "Supervisor execution report status: PG mb mpsocio low" << std::endl; break; } default: sif::warning << "ExecutionReport::printStatusInformation: Invalid status code: 0x" << std::hex << static_cast(statusCode) << std::endl; break; - } } + } }; /** diff --git a/linux/devices/ploc/PlocMPSoCHandler.cpp b/linux/devices/ploc/PlocMPSoCHandler.cpp index 9ca90bcc..da0b0071 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.cpp +++ b/linux/devices/ploc/PlocMPSoCHandler.cpp @@ -99,6 +99,20 @@ 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: { + uartIsolatorSwitch.pullLow(); + return EXECUTION_FINISHED; + break; + } + case mpsoc::RELEASE_UART_TX: { + uartIsolatorSwitch.pullHigh(); + return EXECUTION_FINISHED; + break; + default: + break; + } + } if (plocMPSoCHelperExecuting) { return MPSoCReturnValuesIF::MPSOC_HELPER_EXECUTING; @@ -267,6 +281,8 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { 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); diff --git a/linux/devices/ploc/PlocSupervisorHandler.cpp b/linux/devices/ploc/PlocSupervisorHandler.cpp index cc767037..90b9c14f 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.cpp +++ b/linux/devices/ploc/PlocSupervisorHandler.cpp @@ -827,10 +827,14 @@ ReturnValue_t PlocSupervisorHandler::verifyPacket(const uint8_t* start, size_t f } ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) { - ReturnValue_t result = RETURN_OK; + using namespace supv; + ReturnValue_t result = RETURN_OK; - result = verifyPacket(data, supv::SIZE_ACK_REPORT); - if (result == SupvReturnValuesIF::CRC_FAILURE) { + AcknowledgmentReport ack; + ack.addWholeData(data, SIZE_ACK_REPORT); + + result = ack.checkCrc(); + if (result != RETURN_OK) { sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl; nextReplyId = supv::NONE; replyRawReplyIfnotWiretapped(data, supv::SIZE_ACK_REPORT); @@ -842,7 +846,9 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) { uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - switch (apid) { + result = ack.checkApid(); + + switch (result) { case supv::APID_ACK_FAILURE: { // TODO: Interpretation of status field in acknowledgment report sif::debug << "PlocSupervisorHandler::handleAckReport: Received Ack failure report" @@ -859,7 +865,6 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) { } case supv::APID_ACK_SUCCESS: { setNextReplyId(); - handleSpecialAcknowledgments(data); break; } default: { @@ -887,6 +892,7 @@ ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data) switch (apid) { case (supv::APID_EXE_SUCCESS): { + handleSpecialExecutionReport(data); break; } case (supv::APID_EXE_FAILURE): { @@ -1813,17 +1819,17 @@ ReturnValue_t PlocSupervisorHandler::eventSubscription() { return result; } -void PlocSupervisorHandler::handleSpecialAcknowledgments(const uint8_t* data) { +void PlocSupervisorHandler::handleSpecialExecutionReport(const uint8_t* data) { DeviceCommandId_t commandId = getPendingCommand(); switch(commandId) { case supv::READ_GPIO: { - supv::AcknowledgmentReport ack; - ack.addWholeData(data, supv::SIZE_ACK_REPORT); - uint16_t gpioState = ack.getStatusCode(); + supv::ExecutionReport exe; + exe.addWholeData(data, supv::SIZE_EXE_REPORT); + uint16_t gpioState = exe.getStatusCode(); #if OBSW_DEBUG_PLOC_SUPERVISOR == 1 sif::info << "PlocsupervisorHandler: Read GPIO TM, State: " << gpioState << std::endl; #endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */ - handleDeviceTM(reinterpret_cast(&gpioState), sizeof(gpioState), supv::ACK_REPORT); + handleDeviceTM(reinterpret_cast(&gpioState), sizeof(gpioState), supv::EXE_REPORT); break; } default: diff --git a/linux/devices/ploc/PlocSupervisorHandler.h b/linux/devices/ploc/PlocSupervisorHandler.h index 9fa1bed3..efab17c0 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.h +++ b/linux/devices/ploc/PlocSupervisorHandler.h @@ -351,9 +351,9 @@ class PlocSupervisorHandler : public DeviceHandlerBase { ReturnValue_t eventSubscription(); /** - * @brief Handles acknowledgment reports which contains additional informations in the data field + * @brief Handles execution reports which contains additional information in the data field */ - void handleSpecialAcknowledgments(const uint8_t* data); + void handleSpecialExecutionReport(const uint8_t* data); }; #endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */