Skip to content

Commit

Permalink
🚿 Clean the todo list
Browse files Browse the repository at this point in the history
  • Loading branch information
langroodi committed Jun 22, 2023
1 parent 74cb328 commit 6d9b047
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 41 deletions.
66 changes: 42 additions & 24 deletions src/ara/diag/dtc_information.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
#include "./dtc_information.h"
#include "./diag_error_domain.h"

namespace ara
{
namespace diag
{
DTCInformation::DTCInformation(const ara::core::InstanceSpecifier &specifier) : mSpecifier{specifier},
mControlDtcStatus{ControlDtcStatusType::kDTCSettingOff}
DTCInformation::DTCInformation(const core::InstanceSpecifier &specifier) : mSpecifier{specifier},
mControlDtcStatus{ControlDtcStatusType::kDTCSettingOff}
{
}

ara::core::Result<UdsDtcStatusByteType> DTCInformation::GetCurrentStatus(uint32_t dtc)
core::Result<UdsDtcStatusByteType> DTCInformation::GetCurrentStatus(uint32_t dtc)
{
/// @todo In case of out_of_range exception return kNoSuchDtc (108) error code
UdsDtcStatusByteType _status{mStatuses.at(dtc)};
ara::core::Result<UdsDtcStatusByteType> _result{_status};
try
{
UdsDtcStatusByteType _status{mStatuses.at(dtc)};
core::Result<UdsDtcStatusByteType> _result{_status};

return _result;
return _result;
}
catch (std::out_of_range)
{
core::ErrorDomain *_errorDomain{DiagErrorDomain::GetDiagDomain()};
auto _diagErrorDomain{static_cast<DiagErrorDomain *>(_errorDomain)};
core::ErrorCode _errorCode{_diagErrorDomain->MakeErrorCode(DiagErrc::kNoSuchDTC)};
auto _result{core::Result<UdsDtcStatusByteType>::FromError(_errorCode)};

return _result;
}
}

void DTCInformation::SetCurrentStatus(
Expand Down Expand Up @@ -65,37 +77,37 @@ namespace ara
}
}

ara::core::Result<void> DTCInformation::SetDTCStatusChangedNotifier(
core::Result<void> DTCInformation::SetDTCStatusChangedNotifier(
std::function<void(uint32_t, UdsDtcStatusByteType, UdsDtcStatusByteType)> notifier)
{
// In contrast with the ARA standard, no evaluation is perfomed to validate the notifier pointer.
mDtcStatusChangedNotifier = notifier;
ara::core::Result<void> _result;
core::Result<void> _result;

return _result;
}

ara::core::Result<uint32_t> DTCInformation::GetNumberOfStoredEntries()
core::Result<uint32_t> DTCInformation::GetNumberOfStoredEntries()
{
auto _size{static_cast<uint32_t>(mStatuses.size())};
ara::core::Result<uint32_t> _result{_size};
core::Result<uint32_t> _result{_size};

return _result;
}

ara::core::Result<void> DTCInformation::SetNumberOfStoredEntriesNotifier(
core::Result<void> DTCInformation::SetNumberOfStoredEntriesNotifier(
std::function<void(uint32_t)> notifier)
{
// In contrast with the ARA standard, no evaluation is perfomed to validate the notifier pointer.
mNumberOfStoredEntriesNotifier = notifier;
ara::core::Result<void> _result;
core::Result<void> _result;

return _result;
}

ara::core::Result<void> DTCInformation::Clear(uint32_t dtc)
core::Result<void> DTCInformation::Clear(uint32_t dtc)
{
ara::core::Result<void> _result;

auto _iterator{mStatuses.find(dtc)};

if (_iterator != mStatuses.end())
Expand All @@ -105,34 +117,40 @@ namespace ara
{
mNumberOfStoredEntriesNotifier(mStatuses.size());
}

core::Result<void> _result;
return _result;
}
else
{
/// @todo Return kWrong error code
}
core::ErrorDomain *_errorDomain{DiagErrorDomain::GetDiagDomain()};
auto _diagErrorDomain{static_cast<DiagErrorDomain *>(_errorDomain)};
core::ErrorCode _errorCode{_diagErrorDomain->MakeErrorCode(DiagErrc::kWrongDtc)};
auto _result{core::Result<void>::FromError(_errorCode)};

return _result;
return _result;
}
}

ara::core::Result<ControlDtcStatusType> DTCInformation::GetControlDTCStatus()
core::Result<ControlDtcStatusType> DTCInformation::GetControlDTCStatus()
{
ara::core::Result<ControlDtcStatusType> _result{mControlDtcStatus};
core::Result<ControlDtcStatusType> _result{mControlDtcStatus};
return _result;
}

ara::core::Result<void> DTCInformation::SetControlDtcStatusNotifier(
core::Result<void> DTCInformation::SetControlDtcStatusNotifier(
std::function<void(ControlDtcStatusType)> notifier)
{
// In contrast with the ARA standard, no evaluation is perfomed to validate the notifier pointer.
mControlDtcStatusNotifier = notifier;
ara::core::Result<void> _result;
core::Result<void> _result;

return _result;
}

ara::core::Result<void> DTCInformation::EnableControlDtc()
core::Result<void> DTCInformation::EnableControlDtc()
{
ara::core::Result<void> _result;
core::Result<void> _result;

if (mControlDtcStatus != ControlDtcStatusType::kDTCSettingOn)
{
Expand Down
20 changes: 10 additions & 10 deletions src/ara/diag/dtc_information.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace ara
class DTCInformation
{
private:
const ara::core::InstanceSpecifier &mSpecifier;
const core::InstanceSpecifier &mSpecifier;
std::map<uint32_t, UdsDtcStatusByteType> mStatuses;
std::function<void(uint32_t, UdsDtcStatusByteType, UdsDtcStatusByteType)> mDtcStatusChangedNotifier;
std::function<void(uint32_t)> mNumberOfStoredEntriesNotifier;
Expand All @@ -54,14 +54,14 @@ namespace ara
public:
/// @brief Constructor
/// @param specifier Instance specifier that owns the DTC information
explicit DTCInformation(const ara::core::InstanceSpecifier &specifier);
explicit DTCInformation(const core::InstanceSpecifier &specifier);

~DTCInformation() noexcept = default;

/// @brief Get UDS DTC status byte of a certain DTC
/// @param dtc DTC ID of interest
/// @returns Requested USD DTC status byte if the DTC ID exists, otherwise an error
ara::core::Result<UdsDtcStatusByteType> GetCurrentStatus(uint32_t dtc);
core::Result<UdsDtcStatusByteType> GetCurrentStatus(uint32_t dtc);

/// @brief Set UDS DTC status byte of a certain DTC
/// @param dtc DTC ID of interest
Expand All @@ -74,37 +74,37 @@ namespace ara
/// @brief Set a notifer on any DTC status change
/// @param notifier Callback to be invoked if the status of any DTC is changed
/// @returns Error in case of invalid callback pointer
ara::core::Result<void> SetDTCStatusChangedNotifier(
core::Result<void> SetDTCStatusChangedNotifier(
std::function<void(uint32_t, UdsDtcStatusByteType, UdsDtcStatusByteType)> notifier);

/// @brief Get the number of stored DTC
/// @returns Number of currently stored DTC in the primary fault memory
ara::core::Result<uint32_t> GetNumberOfStoredEntries();
core::Result<uint32_t> GetNumberOfStoredEntries();

/// @brief Set a notifer on the number of stored DTC change
/// @param notifier Callback to be invoked if the number of stored DTC is changed
/// @returns Error in case of invalid callback pointer
ara::core::Result<void> SetNumberOfStoredEntriesNotifier(
core::Result<void> SetNumberOfStoredEntriesNotifier(
std::function<void(uint32_t)> notifier);

/// @brief Clear a DTC
/// @param dtc ID of the DTC that should be removed
/// @returns Error if the requested DTC ID does not exist
ara::core::Result<void> Clear(uint32_t dtc);
core::Result<void> Clear(uint32_t dtc);

/// @brief Indicate whether the UDS DTC byte update is enabled or not
/// @returns Control UDS status relates to the UDS service 0x85
ara::core::Result<ControlDtcStatusType> GetControlDTCStatus();
core::Result<ControlDtcStatusType> GetControlDTCStatus();

/// @brief Set a notifer on the control DTC status change
/// @param notifier Callback to be invoked if the control DTC status is changed
/// @returns Error in case of invalid callback pointer
ara::core::Result<void> SetControlDtcStatusNotifier(
core::Result<void> SetControlDtcStatusNotifier(
std::function<void(ControlDtcStatusType)> notifier);

/// @brief Enforce enabling the USD DTC status byte update
/// @returns No error
ara::core::Result<void> EnableControlDtc();
core::Result<void> EnableControlDtc();
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ara/diag/ecu_reset_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ namespace ara
{
if (mResetTypeFuture.valid())
{
/// @todo Reset the ECU based on the requested reset type
throw std::logic_error("ECU reset is not supported.");
}
else
{
Expand Down
5 changes: 4 additions & 1 deletion src/ara/diag/security_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ namespace ara
MetaInfo &metaInfo,
CancellationHandler &&cancellationHandler)
{
/// @todo Consider the cancellation handler
uint8_t _nrc;
OperationOutput _response;
std::promise<OperationOutput> _resultPromise;
Expand Down Expand Up @@ -99,6 +98,10 @@ namespace ara
_suppressPositiveResponse);
}
}
else if (cancellationHandler.IsCanceled())
{
GenerateNegativeResponse(_response, cGeneralReject);
}
else
{
GenerateNegativeResponse(_response, _nrc);
Expand Down
1 change: 1 addition & 0 deletions src/ara/diag/security_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace ara
const size_t cKeyLength{2};

const uint8_t cSuppressPosRspMask{0x80};
const uint8_t cGeneralReject{0x10};
const uint8_t cInvalidKey{0x35};
const uint8_t cExceededNumberOfAttempts{0x36};

Expand Down
3 changes: 1 addition & 2 deletions src/ara/exec/deterministic_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ namespace ara
{
std::unique_lock<std::mutex> _lock(mCycleMutex);
mCycleConditionVariable.wait(_lock);

/// @todo Return proper value based on the client current lifecycle
core::Result<ActivationReturnType> _result{ActivationReturnType::kRun};

return _result;
}

Expand Down
1 change: 0 additions & 1 deletion src/ara/exec/state_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ namespace ara
core::Result<ExecutionErrorEvent> StateClient::GetExecutionError(
const FunctionGroup &functionGroup) noexcept
{
/// @todo Implement set state tracking
const ExecErrc cExecErrc{ExecErrc::kFailed};
auto _errorValue{static_cast<core::ErrorDomain::CodeType>(cExecErrc)};
core::ErrorCode _errorCode{_errorValue, cErrorDomain};
Expand Down
2 changes: 0 additions & 2 deletions test/ara/diag/ecu_reset_request_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ namespace ara
GeneralMetaInfo,
std::move(_cancellationHander))};
EXPECT_TRUE(_succeedFuture.valid());

EXPECT_NO_THROW(Service.ExecuteReset(GeneralMetaInfo));
}

TEST_F(EcuResetRequestTest, EnableRapidShutdownMethod)
Expand Down

0 comments on commit 6d9b047

Please sign in to comment.