From 7714898b699ab22ddc648db0b6fb471ed4f2028f Mon Sep 17 00:00:00 2001 From: Jerome Hue Date: Mon, 25 Sep 2023 17:02:27 +0200 Subject: [PATCH 1/8] Create an Outcome header This header file contains required definitions and a custom NoValuePolicy that reboots on error. --- Sts1CobcSw/Utility/Outcome.hpp | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Sts1CobcSw/Utility/Outcome.hpp diff --git a/Sts1CobcSw/Utility/Outcome.hpp b/Sts1CobcSw/Utility/Outcome.hpp new file mode 100644 index 00000000..44061735 --- /dev/null +++ b/Sts1CobcSw/Utility/Outcome.hpp @@ -0,0 +1,48 @@ +#pragma once + + +#define OUTCOME_DISABLE_EXECINFO +#define SYSTEM_ERROR2_NOT_POSIX +#define SYSTEM_ERROR2_FATAL(msg) RODOS::hwResetAndReboot() + +#include + +#include + + +struct RebootPolicy : outcome_v2::experimental::policy::base +{ + template + // NOLINTNEXTLINE(readability-identifier-naming) + static constexpr void wide_value_check(Impl && self) + { + //! Call RODOS::hwResetAndReboot() whenever .value() is called on an object that does not + //! contain a value + if(!base::_has_value(std::forward(self))) + { + RODOS::hwResetAndReboot(); + } + } + + template + // NOLINTNEXTLINE(readability-identifier-naming) + static constexpr void wide_error_check(Impl && self) + { + //! Call RODOS::hwResetAndReboot() whenever .error() is called on an object that does not + //! contain an error + if(!base::_has_error(std::forward(self))) + { + RODOS::hwResetAndReboot(); + } + } + + template + // NOLINTNEXTLINE(readability-identifier-naming) + static constexpr void wide_exception_check(Impl && self) + { + if(!base::_has_exception(std::forward(self))) + { + RODOS::hwResetAndReboot(); + } + } +}; From dadf477c6b8aeb459dbd014ad2afd6b1edf97df1 Mon Sep 17 00:00:00 2001 From: Jerome Hue Date: Tue, 26 Sep 2023 08:19:24 +0200 Subject: [PATCH 2/8] Use Result<> for StoreArchive function --- Sts1CobcSw/Edu/Edu.cpp | 2 +- Sts1CobcSw/Edu/Edu.hpp | 6 +++++- Sts1CobcSw/Utility/Outcome.hpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Sts1CobcSw/Edu/Edu.cpp b/Sts1CobcSw/Edu/Edu.cpp index 30eae017..09e0288e 100644 --- a/Sts1CobcSw/Edu/Edu.cpp +++ b/Sts1CobcSw/Edu/Edu.cpp @@ -103,7 +103,7 @@ auto Edu::TurnOff() -> void // TODO: Implement this -auto Edu::StoreArchive([[maybe_unused]] StoreArchiveData const & data) -> std::int32_t +auto Edu::StoreArchive([[maybe_unused]] StoreArchiveData const & data) -> Result { return 0; } diff --git a/Sts1CobcSw/Edu/Edu.hpp b/Sts1CobcSw/Edu/Edu.hpp index 192cc150..f78fdeed 100644 --- a/Sts1CobcSw/Edu/Edu.hpp +++ b/Sts1CobcSw/Edu/Edu.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include @@ -17,6 +18,9 @@ namespace sts1cobcsw::edu { using sts1cobcsw::serial::Byte; +template +using Result = outcome_v2::experimental::status_result; + // TODO: Think about const-correctness and whether to make uart_ mutable or not // @@ -31,7 +35,7 @@ class Edu auto TurnOff() -> void; // TODO: Why does this return a std::int32_t? - [[nodiscard]] auto StoreArchive(StoreArchiveData const & data) -> std::int32_t; + [[nodiscard]] auto StoreArchive(StoreArchiveData const & data) -> Result; [[nodiscard]] auto ExecuteProgram(ExecuteProgramData const & data) -> ErrorCode; [[nodiscard]] auto StopProgram() -> ErrorCode; // TODD: Find better name (or maybe even mechanism) for GetStatus diff --git a/Sts1CobcSw/Utility/Outcome.hpp b/Sts1CobcSw/Utility/Outcome.hpp index 44061735..d91c1d2f 100644 --- a/Sts1CobcSw/Utility/Outcome.hpp +++ b/Sts1CobcSw/Utility/Outcome.hpp @@ -7,7 +7,7 @@ #include -#include +#include struct RebootPolicy : outcome_v2::experimental::policy::base From 60a29afd75ce5763eb539424c16c33fb38656db7 Mon Sep 17 00:00:00 2001 From: Jerome Hue Date: Tue, 26 Sep 2023 09:54:20 +0200 Subject: [PATCH 3/8] WIP : Use Result<> for GetStatus() function --- Sts1CobcSw/Edu/Edu.cpp | 75 +++++++++---------- Sts1CobcSw/Edu/Edu.hpp | 4 +- Sts1CobcSw/Edu/Enums.hpp | 1 - Sts1CobcSw/Edu/Structs.hpp | 4 +- Sts1CobcSw/EduListenerThread.cpp | 22 +++--- .../EduCommandTests/EduCommands.test.cpp | 19 +++-- 6 files changed, 67 insertions(+), 58 deletions(-) diff --git a/Sts1CobcSw/Edu/Edu.cpp b/Sts1CobcSw/Edu/Edu.cpp index 09e0288e..5a6178ee 100644 --- a/Sts1CobcSw/Edu/Edu.cpp +++ b/Sts1CobcSw/Edu/Edu.cpp @@ -215,25 +215,23 @@ auto Edu::StopProgram() -> ErrorCode //! @returns A status containing (Status Type, [Program ID], [Queue ID], [Exit Code], Error //! Code). Values in square brackets are only valid if the relevant Status Type is //! returned. -auto Edu::GetStatus() -> Status +auto Edu::GetStatus() -> Result { RODOS::PRINTF("GetStatus()\n"); auto serialData = serial::Serialize(getStatusId); auto sendDataError = SendData(serialData); if(sendDataError != ErrorCode::success) { - RODOS::PRINTF(" Returned .statusType = %d, .errorCode = %d\n", - static_cast(StatusType::invalid), - static_cast(sendDataError)); - return Status{.statusType = StatusType::invalid, .errorCode = sendDataError}; + RODOS::PRINTF(" Returned .errorCode = %d\n", static_cast(sendDataError)); + return sendDataError; } - Status status; + Result status = ErrorCode::noErrorCodeSet; std::size_t errorCount = 0; do { status = GetStatusCommunication(); - if(status.errorCode == ErrorCode::success) + if(status.has_value()) { SendCommand(cmdAck); break; @@ -242,14 +240,20 @@ auto Edu::GetStatus() -> Status SendCommand(cmdNack); } while(errorCount++ < maxNNackRetries); - RODOS::PRINTF( - " .statusType = %d\n .errorCode = %d\n .programId = %d\n .queueId = %d\n exitCode = " - "%d\n", - static_cast(status.statusType), - static_cast(status.errorCode), - status.programId, - status.queueId, - status.exitCode); + if(status.has_value()) + { + RODOS::PRINTF( + " .statusType = %d\n .programId = %d\n .queueId = %d\n exitCode = " + "%d\n", + status.value().statusType, + status.value().programId, + status.value().queueId, + status.value().exitCode); + } + else + { + RODOS::PRINTF(" .errorCode = %d\n = %d\n", status.error()); + } return status; } @@ -257,7 +261,7 @@ auto Edu::GetStatus() -> Status //! @brief Communication function for GetStatus() to separate a single try from //! retry logic. //! @returns The received EDU status -auto Edu::GetStatusCommunication() -> Status +auto Edu::GetStatusCommunication() -> Result { // Get header data auto headerBuffer = serial::SerialBuffer{}; @@ -266,17 +270,17 @@ auto Edu::GetStatusCommunication() -> Status if(headerReceiveError != ErrorCode::success) { - return Status{.statusType = StatusType::invalid, .errorCode = headerReceiveError}; + return headerReceiveError; } if(headerData.command != cmdData) { - return Status{.statusType = StatusType::invalid, .errorCode = ErrorCode::invalidCommand}; + return ErrorCode::invalidCommand; } if(headerData.length == 0_u16) { - return Status{.statusType = StatusType::invalid, .errorCode = ErrorCode::invalidLength}; + return ErrorCode::invalidLength; } // Get the status type code @@ -285,35 +289,32 @@ auto Edu::GetStatusCommunication() -> Status if(statusErrorCode != ErrorCode::success) { - return Status{.statusType = StatusType::invalid, .errorCode = statusErrorCode}; + return statusErrorCode; } if(statusType == noEventCode) { if(headerData.length != nNoEventBytes) { - return Status{.statusType = StatusType::invalid, .errorCode = ErrorCode::invalidLength}; + return ErrorCode::invalidLength; } std::array statusTypeArray = {statusType}; auto crc32Error = CheckCrc32(std::span(statusTypeArray)); if(crc32Error != ErrorCode::success) { - return Status{.statusType = StatusType::invalid, .errorCode = crc32Error}; + return crc32Error; } - return Status{.statusType = StatusType::noEvent, - .programId = 0, - .queueId = 0, - .exitCode = 0, - .errorCode = ErrorCode::success}; + return Status{ + .statusType = StatusType::noEvent, .programId = 0, .queueId = 0, .exitCode = 0}; } if(statusType == programFinishedCode) { if(headerData.length != nProgramFinishedBytes) { - return Status{.statusType = StatusType::invalid, .errorCode = ErrorCode::invalidLength}; + return ErrorCode::invalidLength; } auto dataBuffer = serial::SerialBuffer{}; @@ -321,7 +322,7 @@ auto Edu::GetStatusCommunication() -> Status if(programFinishedError != ErrorCode::success) { - return Status{.statusType = StatusType::invalid, .errorCode = programFinishedError}; + return programFinishedError; } // Create another Buffer which includes the status type that was received beforehand because @@ -332,29 +333,28 @@ auto Edu::GetStatusCommunication() -> Status auto crc32Error = CheckCrc32(fullDataBuffer); if(crc32Error != ErrorCode::success) { - return Status{.statusType = StatusType::invalid, .errorCode = crc32Error}; + return crc32Error; } auto programFinishedData = serial::Deserialize(dataBuffer); return Status{.statusType = StatusType::programFinished, .programId = programFinishedData.programId, .queueId = programFinishedData.queueId, - .exitCode = programFinishedData.exitCode, - .errorCode = ErrorCode::success}; + .exitCode = programFinishedData.exitCode}; } if(statusType == resultsReadyCode) { if(headerData.length != nResultsReadyBytes) { - return Status{.statusType = StatusType::invalid, .errorCode = ErrorCode::invalidLength}; + return ErrorCode::invalidLength; } auto dataBuffer = serial::SerialBuffer{}; auto resultsReadyError = UartReceive(dataBuffer); if(resultsReadyError != ErrorCode::success) { - return Status{.statusType = StatusType::invalid, .errorCode = resultsReadyError}; + return resultsReadyError; } // Create another Buffer which includes the status type that was received beforehand because @@ -365,16 +365,15 @@ auto Edu::GetStatusCommunication() -> Status auto crc32Error = CheckCrc32(fullDataBuffer); if(crc32Error != ErrorCode::success) { - return Status{.statusType = StatusType::invalid, .errorCode = crc32Error}; + return crc32Error; } auto resultsReadyData = serial::Deserialize(dataBuffer); return Status{.statusType = StatusType::resultsReady, .programId = resultsReadyData.programId, - .queueId = resultsReadyData.queueId, - .errorCode = ErrorCode::success}; + .queueId = resultsReadyData.queueId}; } - return Status{.statusType = StatusType::invalid, .errorCode = ErrorCode::invalidStatusType}; + return ErrorCode::invalidStatusType; } diff --git a/Sts1CobcSw/Edu/Edu.hpp b/Sts1CobcSw/Edu/Edu.hpp index f78fdeed..675000d4 100644 --- a/Sts1CobcSw/Edu/Edu.hpp +++ b/Sts1CobcSw/Edu/Edu.hpp @@ -39,7 +39,7 @@ class Edu [[nodiscard]] auto ExecuteProgram(ExecuteProgramData const & data) -> ErrorCode; [[nodiscard]] auto StopProgram() -> ErrorCode; // TODD: Find better name (or maybe even mechanism) for GetStatus - [[nodiscard]] auto GetStatus() -> Status; + [[nodiscard]] auto GetStatus() -> Result; [[nodiscard]] auto ReturnResult() -> ResultInfo; [[nodiscard]] auto UpdateTime(UpdateTimeData const & data) -> ErrorCode; @@ -53,7 +53,7 @@ class Edu [[nodiscard]] auto UartReceive(void * destination) -> ErrorCode; auto FlushUartBuffer() -> void; [[nodiscard]] auto CheckCrc32(std::span data) -> ErrorCode; - [[nodiscard]] auto GetStatusCommunication() -> Status; + [[nodiscard]] auto GetStatusCommunication() -> Result; [[nodiscard]] auto ReturnResultCommunication() -> ResultInfo; [[nodiscard]] auto ReturnResultRetry() -> ResultInfo; void MockWriteToFile(std::span data); diff --git a/Sts1CobcSw/Edu/Enums.hpp b/Sts1CobcSw/Edu/Enums.hpp index a937fdc9..95b33d75 100644 --- a/Sts1CobcSw/Edu/Enums.hpp +++ b/Sts1CobcSw/Edu/Enums.hpp @@ -34,6 +34,5 @@ enum class StatusType noEvent, programFinished, resultsReady, - invalid, }; } diff --git a/Sts1CobcSw/Edu/Structs.hpp b/Sts1CobcSw/Edu/Structs.hpp index 07ae0684..b641b29a 100644 --- a/Sts1CobcSw/Edu/Structs.hpp +++ b/Sts1CobcSw/Edu/Structs.hpp @@ -55,11 +55,11 @@ struct UpdateTimeData struct Status { - StatusType statusType = StatusType::invalid; + StatusType statusType = StatusType::noEvent; std::uint16_t programId = 0; std::uint16_t queueId = 0; std::uint8_t exitCode = 0; - ErrorCode errorCode = ErrorCode::noErrorCodeSet; + // ErrorCode errorCode = ErrorCode::noErrorCodeSet; }; diff --git a/Sts1CobcSw/EduListenerThread.cpp b/Sts1CobcSw/EduListenerThread.cpp index 6c62b224..248e9fa4 100644 --- a/Sts1CobcSw/EduListenerThread.cpp +++ b/Sts1CobcSw/EduListenerThread.cpp @@ -56,8 +56,10 @@ class EduListenerThread : public RODOS::StaticThread<> // RODOS::PRINTF("EduStatus : %d, EduErrorcode %d\n", status.statusType, // status.errorCode); - if(status.errorCode != edu::ErrorCode::success - and status.errorCode != edu::ErrorCode::successEof) + // FIXME: It is really possible to get edu::errorCode::successEof here ? + // if(status.errorCode != edu::ErrorCode::success + // and status.errorCode != edu::ErrorCode::successEof) + if(status.has_error()) { // RODOS::PRINTF("[EduListenerThread] GetStatus() error code : %d.\n", // status.errorCode); @@ -72,16 +74,18 @@ class EduListenerThread : public RODOS::StaticThread<> // success.\n"); } - switch(status.statusType) + // FIXME: This might lead to wide value check + // It is necessary to add an if condition here + switch(status.value().statusType) { case edu::StatusType::programFinished: { // Program has finished // Find the correspongind queueEntry and update it, then resume edu queue // thread - auto eduProgramStatusHistoryEntry = - edu::FindProgramStatusHistoryEntry(status.programId, status.queueId); - if(status.exitCode == 0) + auto eduProgramStatusHistoryEntry = edu::FindProgramStatusHistoryEntry( + status.value().programId, status.value().queueId); + if(status.value().exitCode == 0) { eduProgramStatusHistoryEntry.status = edu::ProgramStatus::programExecutionSucceeded; @@ -122,15 +126,15 @@ class EduListenerThread : public RODOS::StaticThread<> } // break; - auto eduProgramStatusHistoryEntry = - edu::FindProgramStatusHistoryEntry(status.programId, status.queueId); + auto eduProgramStatusHistoryEntry = edu::FindProgramStatusHistoryEntry( + status.value().programId, status.value().queueId); // TODO: Pretty sure that there is a .put() or something like that missing // here and the status is actually never updated in the ring buffer. eduProgramStatusHistoryEntry.status = edu::ProgramStatus::resultFileTransfered; break; } - case edu::StatusType::invalid: + // case edu::StatusType::invalid: case edu::StatusType::noEvent: { break; diff --git a/Tests/HardwareTests/EduCommandTests/EduCommands.test.cpp b/Tests/HardwareTests/EduCommandTests/EduCommands.test.cpp index 6cb22da3..9169baaa 100644 --- a/Tests/HardwareTests/EduCommandTests/EduCommands.test.cpp +++ b/Tests/HardwareTests/EduCommandTests/EduCommands.test.cpp @@ -99,13 +99,20 @@ class EduCommandsTest : public RODOS::StaticThread<> case 'g': { PRINTF("Sending GetStatus()\n"); - auto status = eduUnit.GetStatus(); + auto result = eduUnit.GetStatus(); PRINTF("Returned status:\n"); - PRINTF(" type = %d\n", static_cast(status.statusType)); - PRINTF(" program ID = %d\n", static_cast(status.programId)); - PRINTF(" queue ID = %d\n", static_cast(status.queueId)); - PRINTF(" exit code = %d\n", static_cast(status.exitCode)); - PRINTF(" error code = %d\n", static_cast(status.errorCode)); + if(result.has_value()) + { + auto status = result.value(); + PRINTF(" type = %d\n", static_cast(status.statusType)); + PRINTF(" program ID = %d\n", static_cast(status.programId)); + PRINTF(" queue ID = %d\n", static_cast(status.queueId)); + PRINTF(" exit code = %d\n", static_cast(status.exitCode)); + } + else + { + PRINTF(" error code = %d\n", static_cast(result.error())); + } break; } case 'r': From ff40cd74c1dfa655896699746dec2399b561429c Mon Sep 17 00:00:00 2001 From: Jerome Hue Date: Wed, 27 Sep 2023 10:36:32 +0200 Subject: [PATCH 4/8] Use Result<> for ReturnResultRetry() and ReturnResultCommunication() --- Sts1CobcSw/Edu/Edu.cpp | 60 ++++++++++++++++++++++-------------------- Sts1CobcSw/Edu/Edu.hpp | 4 +-- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/Sts1CobcSw/Edu/Edu.cpp b/Sts1CobcSw/Edu/Edu.cpp index 5a6178ee..f7d3300e 100644 --- a/Sts1CobcSw/Edu/Edu.cpp +++ b/Sts1CobcSw/Edu/Edu.cpp @@ -397,30 +397,31 @@ auto Edu::ReturnResult() -> ResultInfo ts::size_t totalResultSize = 0_usize; ts::size_t packets = 0_usize; - ResultInfo resultInfo; + Result result = ErrorCode::noErrorCodeSet; + auto errorCode = ErrorCode::success; // TODO: Turn into for loop while(packets < maxNPackets) { // DEBUG // RODOS::PRINTF("\nPacket %d\n", static_cast(packets.get())); // END DEBUG - resultInfo = ReturnResultRetry(); - // DEBUG - RODOS::PRINTF("ResultInfo{errorCode = %d, resultSize = %d}\n", - static_cast(resultInfo.errorCode), - static_cast(resultInfo.resultSize.get())); - // END DEBUG - if(resultInfo.errorCode != ErrorCode::success) + result = ReturnResultRetry(); + if(result.has_error()) { + errorCode = result.error(); + RODOS::PRINTF(" ResultResultRetry() resulted in an error : %d", + static_cast(errorCode)); break; } // RODOS::PRINTF("\nWriting to file...\n"); // TODO: Actually write to a file - totalResultSize += resultInfo.resultSize; + RODOS::PRINTF(" ResultResultRetry() resulted in a success and returned %d ", + static_cast(result.value().get())); + totalResultSize += result.value(); packets++; } - return ResultInfo{.errorCode = resultInfo.errorCode, .resultSize = totalResultSize}; + return ResultInfo{.errorCode = errorCode, .resultSize = totalResultSize}; } @@ -428,23 +429,24 @@ auto Edu::ReturnResult() -> ResultInfo //! the actual ReturnResult function. The communication happens in ReturnResultCommunication. //! //! @returns An error code and the number of received bytes in ResultInfo -auto Edu::ReturnResultRetry() -> ResultInfo +auto Edu::ReturnResultRetry() -> Result { - ResultInfo resultInfo; + Result result = ErrorCode::noErrorCodeSet; std::size_t errorCount = 0U; do { - resultInfo = ReturnResultCommunication(); - if(resultInfo.errorCode == ErrorCode::success - or resultInfo.errorCode == ErrorCode::successEof) + result = ReturnResultCommunication(); + if(result.has_value() or (result.has_error() and result.error() == ErrorCode::successEof)) { - SendCommand(cmdAck); - return resultInfo; + SendCommand(cmdNack); + // Return ts::size_t + return result; } FlushUartBuffer(); SendCommand(cmdNack); } while(errorCount++ < maxNNackRetries); - return resultInfo; + // Return an error + return result; } @@ -452,7 +454,7 @@ auto Edu::ReturnResultRetry() -> ResultInfo // directly and instead writes to a non-primary RAM bank as an intermediate step. // // Simple results -> 1 round should work with DMA to RAM -auto Edu::ReturnResultCommunication() -> ResultInfo +auto Edu::ReturnResultCommunication() -> Result { // Receive command // If no result is available, the command will be NACK, @@ -461,23 +463,25 @@ auto Edu::ReturnResultCommunication() -> ResultInfo auto commandError = UartReceive(&command); if(commandError != ErrorCode::success) { - return ResultInfo{.errorCode = commandError, .resultSize = 0U}; + return commandError; } if(command == cmdNack) { // TODO: necessary to differentiate errors or just return success with resultSize 0? - return ResultInfo{.errorCode = ErrorCode::noResultAvailable, .resultSize = 0U}; + // return ResultInfo{.errorCode = ErrorCode::noResultAvailable, .resultSize = 0U}; + return ErrorCode::noResultAvailable; } if(command == cmdEof) { - return ResultInfo{.errorCode = ErrorCode::successEof, .resultSize = 0U}; + // return ResultInfo{.errorCode = ErrorCode::successEof, .resultSize = 0U}; + return ErrorCode::successEof; } if(command != cmdData) { // DEBUG RODOS::PRINTF("\nNot DATA command\n"); // END DEBUG - return ResultInfo{.errorCode = ErrorCode::invalidCommand, .resultSize = 0U}; + return ErrorCode::invalidCommand; } // DEBUG @@ -488,13 +492,13 @@ auto Edu::ReturnResultCommunication() -> ResultInfo auto lengthError = UartReceive(dataLengthBuffer); if(lengthError != ErrorCode::success) { - return ResultInfo{.errorCode = lengthError, .resultSize = 0U}; + return lengthError; } auto actualDataLength = serial::Deserialize(dataLengthBuffer); if(actualDataLength == 0U or actualDataLength > maxDataLength) { - return ResultInfo{.errorCode = ErrorCode::invalidLength, .resultSize = 0U}; + return ErrorCode::invalidLength; } // DEBUG @@ -507,7 +511,7 @@ auto Edu::ReturnResultCommunication() -> ResultInfo if(dataError != ErrorCode::success) { - return ResultInfo{.errorCode = dataError, .resultSize = 0U}; + return dataError; } // DEBUG @@ -519,14 +523,14 @@ auto Edu::ReturnResultCommunication() -> ResultInfo if(crc32Error != ErrorCode::success) { - return ResultInfo{.errorCode = crc32Error, .resultSize = 0U}; + return crc32Error; } // DEBUG RODOS::PRINTF("\nSuccess\n"); // END DEBUG - return {ErrorCode::success, actualDataLength.get()}; + return actualDataLength; } diff --git a/Sts1CobcSw/Edu/Edu.hpp b/Sts1CobcSw/Edu/Edu.hpp index 675000d4..c05ba372 100644 --- a/Sts1CobcSw/Edu/Edu.hpp +++ b/Sts1CobcSw/Edu/Edu.hpp @@ -54,8 +54,8 @@ class Edu auto FlushUartBuffer() -> void; [[nodiscard]] auto CheckCrc32(std::span data) -> ErrorCode; [[nodiscard]] auto GetStatusCommunication() -> Result; - [[nodiscard]] auto ReturnResultCommunication() -> ResultInfo; - [[nodiscard]] auto ReturnResultRetry() -> ResultInfo; + [[nodiscard]] auto ReturnResultCommunication() -> Result; + [[nodiscard]] auto ReturnResultRetry() -> Result; void MockWriteToFile(std::span data); hal::GpioPin eduEnableGpioPin_ = hal::GpioPin(hal::eduEnablePin); From ebed209e56010c8d130a08cb5960368721bfd5bd Mon Sep 17 00:00:00 2001 From: Jerome Hue Date: Wed, 27 Sep 2023 10:48:45 +0200 Subject: [PATCH 5/8] Use Result<> for CheckCrc32() --- Sts1CobcSw/Edu/Edu.cpp | 25 ++++++++++++------------- Sts1CobcSw/Edu/Edu.hpp | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Sts1CobcSw/Edu/Edu.cpp b/Sts1CobcSw/Edu/Edu.cpp index f7d3300e..663924e6 100644 --- a/Sts1CobcSw/Edu/Edu.cpp +++ b/Sts1CobcSw/Edu/Edu.cpp @@ -301,9 +301,9 @@ auto Edu::GetStatusCommunication() -> Result std::array statusTypeArray = {statusType}; auto crc32Error = CheckCrc32(std::span(statusTypeArray)); - if(crc32Error != ErrorCode::success) + if(crc32Error.has_error()) { - return crc32Error; + return crc32Error.error(); } return Status{ @@ -330,10 +330,10 @@ auto Edu::GetStatusCommunication() -> Result auto fullDataBuffer = std::array{}; fullDataBuffer[0] = statusType; std::copy(dataBuffer.begin(), dataBuffer.end(), fullDataBuffer.begin() + 1); - auto crc32Error = CheckCrc32(fullDataBuffer); - if(crc32Error != ErrorCode::success) + auto crc32Result = CheckCrc32(fullDataBuffer); + if(crc32Result.has_error()) { - return crc32Error; + return crc32Result.error(); } auto programFinishedData = serial::Deserialize(dataBuffer); @@ -362,10 +362,10 @@ auto Edu::GetStatusCommunication() -> Result auto fullDataBuffer = std::array{}; fullDataBuffer[0] = statusType; std::copy(dataBuffer.begin(), dataBuffer.end(), fullDataBuffer.begin() + 1); - auto crc32Error = CheckCrc32(fullDataBuffer); - if(crc32Error != ErrorCode::success) + auto crc32Result = CheckCrc32(fullDataBuffer); + if(crc32Result) { - return crc32Error; + return crc32Result.error(); } auto resultsReadyData = serial::Deserialize(dataBuffer); return Status{.statusType = StatusType::resultsReady, @@ -518,12 +518,12 @@ auto Edu::ReturnResultCommunication() -> Result // RODOS::PRINTF("\nCheck CRC\n"); // END DEBUG - auto crc32Error = CheckCrc32( + auto crc32Result = CheckCrc32( std::span(cepDataBuffer.begin(), cepDataBuffer.begin() + actualDataLength.get())); - if(crc32Error != ErrorCode::success) + if(crc32Result.has_error()) { - return crc32Error; + return crc32Result.error(); } // DEBUG @@ -724,7 +724,7 @@ auto Edu::FlushUartBuffer() -> void } -auto Edu::CheckCrc32(std::span data) -> ErrorCode +auto Edu::CheckCrc32(std::span data) -> Result { auto const computedCrc32 = utility::Crc32(data); @@ -753,7 +753,6 @@ auto Edu::CheckCrc32(std::span data) -> ErrorCode { return ErrorCode::wrongChecksum; } - return ErrorCode::success; } diff --git a/Sts1CobcSw/Edu/Edu.hpp b/Sts1CobcSw/Edu/Edu.hpp index c05ba372..45df7396 100644 --- a/Sts1CobcSw/Edu/Edu.hpp +++ b/Sts1CobcSw/Edu/Edu.hpp @@ -52,7 +52,7 @@ class Edu [[nodiscard]] auto UartReceive(std::span destination) -> ErrorCode; [[nodiscard]] auto UartReceive(void * destination) -> ErrorCode; auto FlushUartBuffer() -> void; - [[nodiscard]] auto CheckCrc32(std::span data) -> ErrorCode; + [[nodiscard]] auto CheckCrc32(std::span data) -> Result; [[nodiscard]] auto GetStatusCommunication() -> Result; [[nodiscard]] auto ReturnResultCommunication() -> Result; [[nodiscard]] auto ReturnResultRetry() -> Result; From 623a4067555689ab4b90ea174adfc53c1187aadd Mon Sep 17 00:00:00 2001 From: Jerome Hue Date: Thu, 28 Sep 2023 12:29:36 +0200 Subject: [PATCH 6/8] Use Result<> for UartReceive() --- Sts1CobcSw/Edu/Edu.cpp | 52 ++++++++++++++++++++---------------------- Sts1CobcSw/Edu/Edu.hpp | 6 ++--- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/Sts1CobcSw/Edu/Edu.cpp b/Sts1CobcSw/Edu/Edu.cpp index 663924e6..3b707fd2 100644 --- a/Sts1CobcSw/Edu/Edu.cpp +++ b/Sts1CobcSw/Edu/Edu.cpp @@ -265,12 +265,12 @@ auto Edu::GetStatusCommunication() -> Result { // Get header data auto headerBuffer = serial::SerialBuffer{}; - auto headerReceiveError = UartReceive(headerBuffer); + auto headerReceiveResult = UartReceive(headerBuffer); auto headerData = serial::Deserialize(headerBuffer); - if(headerReceiveError != ErrorCode::success) + if(headerReceiveResult.has_error()) { - return headerReceiveError; + return headerReceiveResult.error(); } if(headerData.command != cmdData) @@ -285,11 +285,11 @@ auto Edu::GetStatusCommunication() -> Result // Get the status type code auto statusType = 0_b; - auto statusErrorCode = UartReceive(&statusType); + auto statusTypeResult = UartReceive(&statusType); - if(statusErrorCode != ErrorCode::success) + if(statusTypeResult) { - return statusErrorCode; + return statusTypeResult.error(); } if(statusType == noEventCode) @@ -318,11 +318,11 @@ auto Edu::GetStatusCommunication() -> Result } auto dataBuffer = serial::SerialBuffer{}; - auto programFinishedError = UartReceive(dataBuffer); + auto programFinishedResult = UartReceive(dataBuffer); - if(programFinishedError != ErrorCode::success) + if(programFinishedResult.has_error()) { - return programFinishedError; + return programFinishedResult.error(); } // Create another Buffer which includes the status type that was received beforehand because @@ -352,9 +352,9 @@ auto Edu::GetStatusCommunication() -> Result auto dataBuffer = serial::SerialBuffer{}; auto resultsReadyError = UartReceive(dataBuffer); - if(resultsReadyError != ErrorCode::success) + if(resultsReadyError.has_error()) { - return resultsReadyError; + return resultsReadyError.error(); } // Create another Buffer which includes the status type that was received beforehand because @@ -460,10 +460,10 @@ auto Edu::ReturnResultCommunication() -> Result // If no result is available, the command will be NACK, // otherwise DATA Byte command = 0_b; - auto commandError = UartReceive(&command); - if(commandError != ErrorCode::success) + auto commandResult = UartReceive(&command); + if(commandResult.has_error()) { - return commandError; + return commandResult.error(); } if(command == cmdNack) { @@ -489,10 +489,10 @@ auto Edu::ReturnResultCommunication() -> Result // END DEBUG auto dataLengthBuffer = serial::SerialBuffer{}; - auto lengthError = UartReceive(dataLengthBuffer); - if(lengthError != ErrorCode::success) + auto lengthResult = UartReceive(dataLengthBuffer); + if(lengthResult.has_error()) { - return lengthError; + return lengthResult.error(); } auto actualDataLength = serial::Deserialize(dataLengthBuffer); @@ -506,12 +506,12 @@ auto Edu::ReturnResultCommunication() -> Result // END DEBUG // Get the actual data - auto dataError = UartReceive( + auto dataResult = UartReceive( std::span(cepDataBuffer.begin(), cepDataBuffer.begin() + actualDataLength.get())); - if(dataError != ErrorCode::success) + if(dataResult.has_error()) { - return dataError; + return dataResult.error(); } // DEBUG @@ -661,7 +661,7 @@ auto Edu::SendData(std::span data) -> ErrorCode //! //! @returns A relevant EDU error code // TODO: Use hal::ReadFrom() -auto Edu::UartReceive(std::span destination) -> ErrorCode +auto Edu::UartReceive(std::span destination) -> Result { if(size(destination) > maxDataLength) { @@ -681,7 +681,6 @@ auto Edu::UartReceive(std::span destination) -> ErrorCode } totalReceivedBytes += nReceivedBytes; } - return ErrorCode::success; } @@ -691,7 +690,7 @@ auto Edu::UartReceive(std::span destination) -> ErrorCode //! //! @returns A relevant EDU error code // TODO: Use hal::ReadFrom() -auto Edu::UartReceive(void * destination) -> ErrorCode +auto Edu::UartReceive(void * destination) -> Result { uart_.suspendUntilDataReady(RODOS::NOW() + eduTimeout); auto nReceivedBytes = uart_.read(destination, 1); @@ -699,7 +698,6 @@ auto Edu::UartReceive(void * destination) -> ErrorCode { return ErrorCode::timeout; } - return ErrorCode::success; } @@ -737,7 +735,7 @@ auto Edu::CheckCrc32(std::span data) -> Result auto crc32Buffer = serial::SerialBuffer{}; - auto receiveError = UartReceive(crc32Buffer); + auto receiveResult = UartReceive(crc32Buffer); // DEBUG // RODOS::PRINTF("Received CRC: "); @@ -745,9 +743,9 @@ auto Edu::CheckCrc32(std::span data) -> Result // RODOS::PRINTF("\n"); // END DEBUG - if(receiveError != ErrorCode::success) + if(receiveResult.has_error()) { - return receiveError; + return receiveResult; } if(computedCrc32 != serial::Deserialize(crc32Buffer)) { diff --git a/Sts1CobcSw/Edu/Edu.hpp b/Sts1CobcSw/Edu/Edu.hpp index 45df7396..bfa2fe32 100644 --- a/Sts1CobcSw/Edu/Edu.hpp +++ b/Sts1CobcSw/Edu/Edu.hpp @@ -48,9 +48,9 @@ class Edu auto SendCommand(Byte commandId) -> void; [[nodiscard]] auto SendData(std::span data) -> ErrorCode; // TODO: Make this read and return a Type instead of having to provide a destination. Use - // Deserialize<>() internally. - [[nodiscard]] auto UartReceive(std::span destination) -> ErrorCode; - [[nodiscard]] auto UartReceive(void * destination) -> ErrorCode; + // Deserialize<>() internally + [[nodiscard]] auto UartReceive(std::span destination) -> Result; + [[nodiscard]] auto UartReceive(void * destination) -> Result; auto FlushUartBuffer() -> void; [[nodiscard]] auto CheckCrc32(std::span data) -> Result; [[nodiscard]] auto GetStatusCommunication() -> Result; From 6e660088b28f00c9c0d7dbc5ff20c9d019119694 Mon Sep 17 00:00:00 2001 From: Jerome Hue Date: Sun, 15 Oct 2023 11:10:27 +0200 Subject: [PATCH 7/8] Change return type of SendData() --- Sts1CobcSw/Edu/Edu.cpp | 36 +++++++++---------- Sts1CobcSw/Edu/Edu.hpp | 6 ++-- Sts1CobcSw/EduProgramQueueThread.cpp | 6 ++-- .../EduCommandTests/EduCommands.test.cpp | 6 ++-- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/Sts1CobcSw/Edu/Edu.cpp b/Sts1CobcSw/Edu/Edu.cpp index 3b707fd2..ec841d00 100644 --- a/Sts1CobcSw/Edu/Edu.cpp +++ b/Sts1CobcSw/Edu/Edu.cpp @@ -128,7 +128,7 @@ auto Edu::StoreArchive([[maybe_unused]] StoreArchiveData const & data) -> Result //! @param timeout The available execution time for the student program //! //! @returns A relevant error code -auto Edu::ExecuteProgram(ExecuteProgramData const & data) -> ErrorCode +auto Edu::ExecuteProgram(ExecuteProgramData const & data) -> Result { RODOS::PRINTF("ExecuteProgram(programId = %d, queueId = %d, timeout = %d)\n", data.programId.get(), @@ -136,11 +136,7 @@ auto Edu::ExecuteProgram(ExecuteProgramData const & data) -> ErrorCode data.timeout.get()); // Check if data command was successful auto serialData = serial::Serialize(data); - auto errorCode = SendData(serialData); - if(errorCode != ErrorCode::success) - { - return errorCode; - } + OUTCOME_TRY(SendData(serialData)); // eduTimeout != timeout argument for data! // timeout specifies the time the student program has to execute @@ -219,11 +215,11 @@ auto Edu::GetStatus() -> Result { RODOS::PRINTF("GetStatus()\n"); auto serialData = serial::Serialize(getStatusId); - auto sendDataError = SendData(serialData); - if(sendDataError != ErrorCode::success) + auto sendDataResult = SendData(serialData); + if(sendDataResult.has_error()) { - RODOS::PRINTF(" Returned .errorCode = %d\n", static_cast(sendDataError)); - return sendDataError; + RODOS::PRINTF(" Returned .errorCode = %d\n", static_cast(sendDataResult.error())); + return sendDataResult.error(); } Result status = ErrorCode::noErrorCodeSet; @@ -385,10 +381,10 @@ auto Edu::ReturnResult() -> ResultInfo // Send command auto serialCommand = serial::Serialize(returnResultId); - auto commandError = SendData(serialCommand); - if(commandError != ErrorCode::success) + auto sendCommandResult = SendData(serialCommand); + if(sendCommandResult.has_error()) { - return ResultInfo{.errorCode = commandError, .resultSize = 0U}; + return ResultInfo{.errorCode = sendCommandResult.error(), .resultSize = 0U}; } // DEBUG @@ -549,15 +545,15 @@ auto Edu::ReturnResultCommunication() -> Result //! @param timestamp A unix timestamp //! //! @returns A relevant error code -auto Edu::UpdateTime(UpdateTimeData const & data) -> ErrorCode +auto Edu::UpdateTime(UpdateTimeData const & data) -> Result { RODOS::PRINTF("UpdateTime()\n"); auto serialData = serial::Serialize(data); - auto errorCode = SendData(serialData); - if(errorCode != ErrorCode::success) - { - return errorCode; - } + OUTCOME_TRY(SendData(serialData)) + // if(errorCode != ErrorCode::success) + //{ + // return errorCode; + // } // On success, wait for second N/ACK // TODO: (Daniel) Change to UartReceive() @@ -603,7 +599,7 @@ void Edu::SendCommand(Byte commandId) //! @brief Send a data packet over UART to the EDU. //! //! @param data The data to be sent -auto Edu::SendData(std::span data) -> ErrorCode +auto Edu::SendData(std::span data) -> Result { std::size_t const nBytes = data.size(); if(nBytes >= maxDataLength) diff --git a/Sts1CobcSw/Edu/Edu.hpp b/Sts1CobcSw/Edu/Edu.hpp index bfa2fe32..c3de694b 100644 --- a/Sts1CobcSw/Edu/Edu.hpp +++ b/Sts1CobcSw/Edu/Edu.hpp @@ -36,17 +36,17 @@ class Edu // TODO: Why does this return a std::int32_t? [[nodiscard]] auto StoreArchive(StoreArchiveData const & data) -> Result; - [[nodiscard]] auto ExecuteProgram(ExecuteProgramData const & data) -> ErrorCode; + [[nodiscard]] auto ExecuteProgram(ExecuteProgramData const & data) -> Result; [[nodiscard]] auto StopProgram() -> ErrorCode; // TODD: Find better name (or maybe even mechanism) for GetStatus [[nodiscard]] auto GetStatus() -> Result; [[nodiscard]] auto ReturnResult() -> ResultInfo; - [[nodiscard]] auto UpdateTime(UpdateTimeData const & data) -> ErrorCode; + [[nodiscard]] auto UpdateTime(UpdateTimeData const & data) -> Result; private: // TODO: Rework -> Send(EduBasicCommand command) -> void; auto SendCommand(Byte commandId) -> void; - [[nodiscard]] auto SendData(std::span data) -> ErrorCode; + [[nodiscard]] auto SendData(std::span data) -> Result; // TODO: Make this read and return a Type instead of having to provide a destination. Use // Deserialize<>() internally [[nodiscard]] auto UartReceive(std::span destination) -> Result; diff --git a/Sts1CobcSw/EduProgramQueueThread.cpp b/Sts1CobcSw/EduProgramQueueThread.cpp index 18cc6a13..ac43cf95 100644 --- a/Sts1CobcSw/EduProgramQueueThread.cpp +++ b/Sts1CobcSw/EduProgramQueueThread.cpp @@ -104,9 +104,9 @@ class EduProgramQueueThread : public RODOS::StaticThread auto errorCode = eduUnit.UpdateTime(edu::UpdateTimeData{.timestamp = utility::GetUnixUtc()}); - if(errorCode != edu::ErrorCode::success) + if(errorCode.has_error()) { - RODOS::PRINTF("UpdateTime error code : %d\n", static_cast(errorCode)); + RODOS::PRINTF("UpdateTime error code : %d\n", static_cast(errorCode.error())); RODOS::PRINTF( "[EduProgramQueueThread] Communication error after call to UpdateTime().\n"); ResumeEduCommunicationErrorThread(); @@ -138,7 +138,7 @@ class EduProgramQueueThread : public RODOS::StaticThread errorCode = eduUnit.ExecuteProgram(executeProgramData); // errorCode = periphery::EduErrorCode::success; - if(errorCode != edu::ErrorCode::success) + if(errorCode.has_error()) { RODOS::PRINTF( "[EduProgramQueueThread] Communication error after call to " diff --git a/Tests/HardwareTests/EduCommandTests/EduCommands.test.cpp b/Tests/HardwareTests/EduCommandTests/EduCommands.test.cpp index 9169baaa..20dcb230 100644 --- a/Tests/HardwareTests/EduCommandTests/EduCommands.test.cpp +++ b/Tests/HardwareTests/EduCommandTests/EduCommands.test.cpp @@ -64,7 +64,8 @@ class EduCommandsTest : public RODOS::StaticThread<> auto timestamp = utility::GetUnixUtc(); PRINTF("Sending UpdateTime(timestamp = %d)\n", static_cast(timestamp)); auto errorCode = eduUnit.UpdateTime({.timestamp = timestamp}); - PRINTF("Returned error code: %d\n", static_cast(errorCode)); + PRINTF("Returned error code: %d\n", + errorCode.has_error() ? static_cast(errorCode.assume_error()) : 0); break; } case 'e': @@ -93,7 +94,8 @@ class EduCommandsTest : public RODOS::StaticThread<> static_cast(timeout)); auto errorCode = eduUnit.ExecuteProgram( {.programId = programId, .queueId = queueId, .timeout = timeout}); - PRINTF("Returned error code: %d\n", static_cast(errorCode)); + PRINTF("Returned error code: %d\n", + errorCode.has_error() ? static_cast(errorCode.assume_error()) : 0); break; } case 'g': From 178afef1588da9c689c0bdc151c8dd1bb665289d Mon Sep 17 00:00:00 2001 From: Jerome Hue Date: Sun, 15 Oct 2023 12:02:14 +0200 Subject: [PATCH 8/8] Update CMakeLists.txt and EduMock.cpp In CMakeLists.txt, specify GENERIC_SYSTEM or LINUX_SYSTEM definitions. Bases on these definitions, Utility/Outcome.hpp will correctly define things and import Updated EduMock.cpp to reflect changes mades to Edu.hpp in the previous commits. --- Sts1CobcSw/Edu/CMakeLists.txt | 2 ++ Sts1CobcSw/Edu/EduMock.cpp | 28 +++++++++++++--------------- Sts1CobcSw/Utility/Outcome.hpp | 8 +++++--- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Sts1CobcSw/Edu/CMakeLists.txt b/Sts1CobcSw/Edu/CMakeLists.txt index 0c4c5bd9..50b9bba1 100644 --- a/Sts1CobcSw/Edu/CMakeLists.txt +++ b/Sts1CobcSw/Edu/CMakeLists.txt @@ -5,7 +5,9 @@ target_link_libraries(Sts1CobcSw_Edu PRIVATE Sts1CobcSw_Utility) if(CMAKE_SYSTEM_NAME STREQUAL Generic) target_sources(Sts1CobcSw_Edu PRIVATE Edu.cpp) target_link_libraries(Sts1CobcSw_Edu PUBLIC Sts1CobcSw_Hal) + target_compile_definitions(Sts1CobcSw_Edu PUBLIC GENERIC_SYSTEM) endif() if(CMAKE_SYSTEM_NAME STREQUAL Linux) target_sources(Sts1CobcSw_Edu PRIVATE EduMock.cpp) + target_compile_definitions(Sts1CobcSw_Edu PUBLIC LINUX_SYSTEM) endif() diff --git a/Sts1CobcSw/Edu/EduMock.cpp b/Sts1CobcSw/Edu/EduMock.cpp index c7ccb2db..9bfe971d 100644 --- a/Sts1CobcSw/Edu/EduMock.cpp +++ b/Sts1CobcSw/Edu/EduMock.cpp @@ -1,6 +1,8 @@ #include #include +#include + namespace sts1cobcsw { @@ -53,7 +55,7 @@ auto Edu::TurnOff() -> void // NOLINTNEXTLINE(readability-convert-member-functions-to-static) -auto Edu::StoreArchive(StoreArchiveData const & data) -> std::int32_t +auto Edu::StoreArchive(StoreArchiveData const & data) -> Result { PrintFormattedSystemUtc(); PRINTF("Call to StoreArchive(programId = %d)\n", data.programId.get()); @@ -62,14 +64,14 @@ auto Edu::StoreArchive(StoreArchiveData const & data) -> std::int32_t // NOLINTNEXTLINE(readability-convert-member-functions-to-static) -auto Edu::ExecuteProgram(ExecuteProgramData const & data) -> ErrorCode +auto Edu::ExecuteProgram(ExecuteProgramData const & data) -> Result { PrintFormattedSystemUtc(); PRINTF("Call to ExecuteProgram(programId = %d, queueId = %d, timeout = %d)\n", data.programId.get(), data.queueId.get(), data.timeout.get()); - return ErrorCode::success; + // NOLINTNEXTLINE(clang-diagnostic-return-type) } @@ -83,24 +85,20 @@ auto Edu::StopProgram() -> ErrorCode // NOLINTNEXTLINE(readability-convert-member-functions-to-static) -auto Edu::GetStatus() -> Status +auto Edu::GetStatus() -> Result { PrintFormattedSystemUtc(); PRINTF("Call to GetStatus()\n"); - return {.statusType = StatusType::invalid, - .programId = 0, - .queueId = 0, - .exitCode = 0, - .errorCode = ErrorCode::success}; + return Status{.statusType = StatusType::noEvent, .programId = 0, .queueId = 0, .exitCode = 0}; } // NOLINTNEXTLINE(readability-convert-member-functions-to-static) -auto Edu::UpdateTime(UpdateTimeData const & data) -> ErrorCode +auto Edu::UpdateTime(UpdateTimeData const & data) -> Result { PrintFormattedSystemUtc(); PRINTF("Call to UpdateTime(timestamp = %d)\n", data.timestamp.get()); - return ErrorCode::success; + // NOLINTNEXTLINE(clang-diagnostic-return-type) } @@ -113,20 +111,20 @@ auto Edu::SendCommand(Byte commandId) -> void // NOLINTNEXTLINE(readability-convert-member-functions-to-static) -auto Edu::SendData(std::span data) -> ErrorCode +auto Edu::SendData(std::span data) -> Result { PrintFormattedSystemUtc(); PRINTF("Call to SendData(size(data) = %d)\n", size(data)); - return ErrorCode::success; + // NOLINTNEXTLINE(clang-diagnostic-return-type) } // NOLINTNEXTLINE(readability-convert-member-functions-to-static) -auto Edu::UartReceive([[maybe_unused]] std::span destination) -> ErrorCode +auto Edu::UartReceive([[maybe_unused]] std::span destination) -> Result { PrintFormattedSystemUtc(); PRINTF("Call to UartReceive(size(destination) = %d)\n", size(destination)); - return ErrorCode::success; + // NOLINTNEXTLINE(clang-diagnostic-return-type) } diff --git a/Sts1CobcSw/Utility/Outcome.hpp b/Sts1CobcSw/Utility/Outcome.hpp index d91c1d2f..131c9981 100644 --- a/Sts1CobcSw/Utility/Outcome.hpp +++ b/Sts1CobcSw/Utility/Outcome.hpp @@ -1,9 +1,11 @@ #pragma once +#if defined(GENERIC_SYSTEM) + #define OUTCOME_DISABLE_EXECINFO + #define SYSTEM_ERROR2_NOT_POSIX + #define SYSTEM_ERROR2_FATAL(msg) RODOS::hwResetAndReboot() +#endif -#define OUTCOME_DISABLE_EXECINFO -#define SYSTEM_ERROR2_NOT_POSIX -#define SYSTEM_ERROR2_FATAL(msg) RODOS::hwResetAndReboot() #include