Skip to content

Commit

Permalink
Minor improvement in code and test
Browse files Browse the repository at this point in the history
  • Loading branch information
Iandiehard committed Oct 5, 2023
1 parent 8833eef commit 13c5d95
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* [Diagnostic Client Library](#diagnostic-client-library)
* [Diagnostic Client Library](#diagnostic-client-library-1)
* [Overview](#overview)
* [Documentation](#documentation)
* [Get Started](#get-started)
* [Build and Install](#build-and-install)
* [In Linux :-](#in-linux--)
Expand Down Expand Up @@ -43,7 +44,7 @@ Diagnostic Client library supports below Diagnostic Protocols :-
Diagnostic Client library supports opening of multiple conversation(tester instance) for sending diagnostic request to multiple ECU at the same time.

## Documentation
[Github pages](https://iandiehard.github.io/diag-client-lib/) is used to publish the documentation of this project using Doxygen.
The documentation of this project can be found here [GitHub pages](https://iandiehard.github.io/diag-client-lib/)

## Get Started
In this section, you will learn how to [build and install](#build-and-install)
Expand Down
6 changes: 6 additions & 0 deletions diag-client-lib/appl/src/dcm/conversation/vd_conversation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@ VdConversation::SendVehicleIdentificationRequest(
if (vehicle_info_collection_.empty()) {
// no response received
result.EmplaceError(DiagClient::VehicleInfoResponseError::kNoResponseReceived);
logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogWarn(
__FILE__, __LINE__, __func__, [&](std::stringstream &msg) {
msg << "'" << conversation_name_ << "'"
<< "-> "
<< "No vehicle identification response received, timed out without response";
});
} else {
result.EmplaceValue(std::make_unique<VehicleInfoMessageImpl>(vehicle_info_collection_));
// all the responses are copied, now clear the map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,24 +273,32 @@ auto VehicleIdentificationHandler::HandleVehicleIdentificationRequest(
uds_transport::UdsTransportProtocolMgr::TransmissionResult ret_val{
uds_transport::UdsTransportProtocolMgr::TransmissionResult::kTransmitFailed};
if (handler_impl_->GetStateContext().GetActiveState().GetState() == VehicleIdentificationState::kIdle) {
// change state before sending if SendVehicleIdentificationRequest call takes more time to return and in the
// same time async reception starts
handler_impl_->GetStateContext().TransitionTo(VehicleIdentificationState::kWaitForVehicleIdentificationRes);
if (SendVehicleIdentificationRequest(std::move(vehicle_identification_request)) ==
uds_transport::UdsTransportProtocolMgr::TransmissionResult::kTransmitOk) {
ret_val = uds_transport::UdsTransportProtocolMgr::TransmissionResult::kTransmitOk;

handler_impl_->GetStateContext().TransitionTo(VehicleIdentificationState::kWaitForVehicleIdentificationRes);
// Wait for 2 sec to collect all the vehicle identification response
handler_impl_->GetSyncTimer().WaitForTimeout(
[&]() { handler_impl_->GetStateContext().TransitionTo(VehicleIdentificationState::kDoIPCtrlTimeout); },
[&]() {
// do nothing
handler_impl_->GetStateContext().TransitionTo(VehicleIdentificationState::kDoIPCtrlTimeout);
// Todo: Send data to upper layer here
},
[&]() {
// no cancellation
},
std::chrono::milliseconds{kDoIPCtrl});
handler_impl_->GetStateContext().TransitionTo(VehicleIdentificationState::kIdle);
} else {
// failed, do nothing
handler_impl_->GetStateContext().TransitionTo(VehicleIdentificationState::kIdle);
logger::DoipClientLogger::GetDiagClientLogger().GetLogger().LogError(
__FILE__, __LINE__, "",
[](std::stringstream &msg) { msg << "Vehicle Identification request transmission Failed"; });
}
} else {
// not free
// not free, state already in idle state
}
return ret_val;
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_case/diag_request_response_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ TEST_F(DiagReqResFixture, VerifyDiagReqResponseWithVehicleDiscovery) {
auto diag_result{diag_client_conversation.SendDiagnosticRequest(std::move(uds_message))};

// Verify positive response
EXPECT_TRUE(diag_result.HasValue());
EXPECT_TRUE(diag_result.HasValue()) << " Error received, code: " << static_cast<int>(diag_result.Error());
EXPECT_EQ(diag_result.Value()->GetPayload()[0], 0x50);
EXPECT_EQ(diag_result.Value()->GetPayload()[1], 0x01);

Expand Down

0 comments on commit 13c5d95

Please sign in to comment.