Skip to content

Commit

Permalink
Update example and readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
Iandiehard committed Dec 24, 2024
1 parent 69d63fa commit 0e9b971
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 93 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/gcc11.yml

This file was deleted.

111 changes: 79 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
# Diagnostic Client Library

[![Clang14](https://github.com/Iandiehard/diag-client-lib/actions/workflows/clang14.yml/badge.svg)](https://github.com/Iandiehard/diag-client-lib/actions/workflows/clang14.yml)
[![Gcc9](https://github.com/Iandiehard/diag-client-lib/actions/workflows/gcc9.yml/badge.svg)](https://github.com/Iandiehard/diag-client-lib/actions/workflows/gcc9.yml)
[![Gcc9_GTest](https://github.com/Iandiehard/diag-client-lib/actions/workflows/gcc9_with_test.yml/badge.svg)](https://github.com/Iandiehard/diag-client-lib/actions/workflows/gcc9_with_test.yml)
[![Gcc11](https://github.com/Iandiehard/diag-client-lib/actions/workflows/gcc11.yml/badge.svg)](https://github.com/Iandiehard/diag-client-lib/actions/workflows/gcc11.yml)

<!-- TOC -->

* [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--)
* [In Windows :-](#in-windows--)
* [How to use diag-client-lib](#how-to-use-diag-client-lib)
* [Logging in diag-client-lib](#logging-in-diag-client-lib)
* [Documentation in diag-client-lib](#documentation-in-diag-client-lib)
* [Requirements](#requirements)
* [Known Defect](#known-defect)
* [Future Work](#future-work)
* [License](#license)
* [Contact](#contact)
* [Author](#author)
* [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--)
* [In Windows :-](#in-windows--)
* [How to use diag-client-lib](#how-to-use-diag-client-lib)
* [Logging in diag-client-lib](#logging-in-diag-client-lib)
* [Documentation in diag-client-lib](#documentation-in-diag-client-lib)
* [Requirements](#requirements)
* [Known Defect](#known-defect)
* [Future Work](#future-work)
* [License](#license)
* [Contact](#contact)
* [Author](#author)

<!-- TOC -->

## Diagnostic Client Library

Welcome to Diagnostic Client library that is developed based on motivation taken from
[Adaptive AUTOSAR Diagnostic Specification 21-11](https://www.autosar.org/fileadmin/standards/R21-11/AP/AUTOSAR_SWS_Diagnostics.pdf)

Expand All @@ -33,26 +35,32 @@ Some internal APIs is implemented based on API Reference mentioned in
[Adaptive AUTOSAR Diagnostic Specification 21-11](https://www.autosar.org/fileadmin/standards/R21-11/AP/AUTOSAR_SWS_Diagnostics.pdf)

## Overview
Diagnostic Client library acts as diagnostic tester library that is linked to a user application which wants to send diagnostic

Diagnostic Client library acts as diagnostic tester library that is linked to a user application which wants to send
diagnostic
requests to multiple ECU over a network.

Diagnostic Client library supports below Diagnostic Protocols :-

- DoIP (Diagnostic over Internet Protocol)
- UDS (Unified Diagnostic Services)

Diagnostic Client library supports opening of multiple conversation(tester instance) for sending diagnostic request to multiple ECU at the same time.
Diagnostic Client library supports opening of multiple conversation(tester instance) for sending diagnostic request to
multiple ECU at the same time.

## Documentation

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)
Diagnostic Client Library and also learn [how to use diag-client-lib](#how-to-use-diag-client-lib)

### Build and Install

#### In Linux :-

The following packages are needed to build and install Diagnostic Client library:-

| Package | Usage | Recommended version |
Expand All @@ -62,88 +70,127 @@ The following packages are needed to build and install Diagnostic Client library
| [Boost](https://www.boost.org/) | asio operation | \>= 1.79.0 |

You can also execute to install dependencies :-

```bash
sh .github/setup.sh
```

#### In Windows :-

The following packages are needed to build and install Diagnostic Client library:-

| Package | Usage | Recommended version |
|---------------------------------------------------------------|-------------------|---------------------|
| [CMake](https://cmake.org/cmake/help/latest/release/3.5.html) | build system | \>=3.5 |
| [Boost](https://www.boost.org/) | asio operation | \>= 1.79.0 |

Note: Covesa DLT is not directly supported in Windows. For more information see [Dlt Issue](https://github.com/COVESA/dlt-daemon/issues/136)
| Package | Usage | Recommended version |
|---------------------------------------------------------------|----------------|---------------------|
| [CMake](https://cmake.org/cmake/help/latest/release/3.5.html) | build system | \>=3.5 |
| [Boost](https://www.boost.org/) | asio operation | \>= 1.79.0 |

Note: Covesa DLT is not directly supported in Windows. For more information
see [Dlt Issue](https://github.com/COVESA/dlt-daemon/issues/136)

### How to use diag-client-lib

Diagnostic Client Library has to be linked first either statically or dynamically with executable before usage.
Diagnostic Client library can be built as shared library by setting the below CMake Flag to ON

```cmake
BUILD_SHARED_LIBS : ON
```

Main instance of Diagnostic Client Library must be created using `CreateDiagnosticClient` method call by passing the path to
Main instance of Diagnostic Client Library must be created using `CreateDiagnosticClient` method call by passing the
path to
[diag-client config json](diag-client-lib/appl/etc/diag_client_config.json) file as parameter.

```cpp
// Create the Diagnostic client and pass the config for creating internal properties
std::unique_ptr<diag::client::DiagClient> diag_client{
diag::client::CreateDiagnosticClient("etc/diag_client_config.json")};
```
[diag-client config json](diag-client-lib/appl/etc/diag_client_config.json) file can be modified as per user requirements.
Once Diagnostic Client Library is instantiated and initialized, `GetDiagnosticClientConversation` can be used to get the tester/conversation instance
[diag-client config json](diag-client-lib/appl/etc/diag_client_config.json) file can be modified as per user
requirements.
Once Diagnostic Client Library is instantiated and initialized, `GetDiagnosticClientConversation` can be used to get the
tester/conversation instance
by passing the tester/conversation name.
```cpp
// Get conversation for tester one by providing the conversation name configured
// in diag_client_config file passed while creating the diag client
diag::client::conversation::DiagClientConversation diag_client_conversation {
diag_client->GetDiagnosticClientConversation("DiagTesterOne")};
```

Multiple tester instance can be created using these method as provided in the configuration json file.

Check the example application [Examples](examples) on how Diagnostic Client Library can be linked and used.
It also supports finding the available Diagnostic ECUs in the whole network through vehicle discovery.

```cpp
// Create a vehicle info request for finding available ECU in the whole network,
// Use preselection mode `0` for broadcasting vehicle identification request to the whole network
diag::client::vehicle_info::VehicleInfoListRequestType const vehicle_info_request{0u, ""};
// Send Vehicle Identification request and get the response with available ECU information
diag::client::Result<diag::client::vehicle_info::VehicleInfoMessageResponseUniquePtr,
diag::client::DiagClient::VehicleInfoResponseError> const
vehicle_response_result{diag_client->SendVehicleIdentificationRequest(vehicle_info_request)};

```
Check the [example](examples) application on how Diagnostic Client Library can be linked and used.
Example can be built too by enabling CMake Flag:-
```cmake
BUILD_EXAMPLES : ON
```

### Logging in diag-client-lib
Diagnostic Client Library supports logging and tracing by using the logging infrastructure from [COVESA DLT](https://github.com/COVESA/dlt-daemon).

Diagnostic Client Library supports logging and tracing by using the logging infrastructure
from [COVESA DLT](https://github.com/COVESA/dlt-daemon).
Logging is switched OFF by default using the CMake Flag, can be switched ON by enabling the flag:-

```cmake
BUILD_WITH_DLT : ON
```

Note: DLT logging is not supported in Windows. So, CMake Flag must be switched OFF.

### Documentation in diag-client-lib
Diagnostic Client Library uses doxygen to generate the documentation of the public api's.

Diagnostic Client Library uses doxygen to generate the documentation of the public api's.
Doxygen build is switched OFF by default using the CMake Flag, can be switched ON by enabling the flag:-

```cmake
BUILD_DOXYGEN : ON
```

In the future, we will have internal code documentation too.

## Requirements

Component requirements implemented are documented [REQ](docs/requirement/requirements.md)

## Known Defect

* No defect is identified yet.

You can add new issues with label `bug` for notifying us about any defect in library.

## Future Work

* Improve internal API documentation
* DoIP with TLS

For adding more features you can add new issues with label `enhancement` so that we can work on it.

## License

Full information on project license is available here [LICENSE](LICENSE).
Boost License is available here [LICENSE](diag-client-lib/lib/boost-support/LICENSE).

## Contact

For any other queries regarding `diag-client-lib`, please drop a mail to `iandiehard@outlook.com`.

## Author

Original idea, design and implementation done by Avijit Dey `iandiehard@outlook.com`.
4 changes: 2 additions & 2 deletions examples/example_1/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int main() {
using DiagClientConversation = diag::client::conversation::DiagClientConversation;

// Create the Diagnostic client and pass the config for creating internal properties
std::unique_ptr<diag::client::DiagClient> diag_client{
std::unique_ptr const diag_client{
diag::client::CreateDiagnosticClient("etc/diag_client_config.json")};

// Initialize the Diagnostic Client library
Expand Down Expand Up @@ -114,5 +114,5 @@ int main() {

// important to release all the resources by calling de-initialize
diag_client->DeInitialize();
return (0);
return 0;
}
71 changes: 37 additions & 34 deletions examples/example_2/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,74 +21,77 @@
* This is an example to find available ECU in a network through vehicle discovery and connecting to it.
*/
int main() {
// Type alias for diag client conversation
using DiagClientConversation = diag::client::conversation::DiagClientConversation;

// Create the Diagnostic client and pass the config for creating internal properties
std::unique_ptr<diag::client::DiagClient> diag_client{
std::unique_ptr const diag_client{
diag::client::CreateDiagnosticClient("etc/diag_client_config.json")};

// Initialize the Diagnostic Client library
diag_client->Initialize();
/*

// Get conversation for tester one by providing the conversation name configured
// in diag_client_config file passed while creating the diag client
diag::client::conversation::DiagClientConversation &diag_client_conversation {
DiagClientConversation diag_client_conversation{
diag_client->GetDiagnosticClientConversation("DiagTesterOne")};

// Start the conversation for tester one
diag_client_conversation.Startup();
// Create a vehicle info request for finding ECU with matching VIN - ABCDEFGH123456789
diag::client::vehicle_info::VehicleInfoListRequestType
vehicle_info_request{1U, "ABCDEFGH123456789"};
// Create a vehicle info request for finding available ECU in the whole network
// Use preselection mode `0` for broadcasting vehicle identification request to whole network
diag::client::vehicle_info::VehicleInfoListRequestType const vehicle_info_request{0u, ""};
// Send Vehicle Identification request and get the response with available ECU information
std::pair<diag::client::DiagClient::VehicleResponseResult,
diag::client::vehicle_info::VehicleInfoMessageResponseUniquePtr>
diag::client::Result<diag::client::vehicle_info::VehicleInfoMessageResponseUniquePtr,
diag::client::DiagClient::VehicleInfoResponseError> const
vehicle_response_result{diag_client->SendVehicleIdentificationRequest(vehicle_info_request)};

// Valid vehicle discovery response must be received before connecting to ECU
if(vehicle_response_result.first == diag::client::DiagClient::VehicleResponseResult::kStatusOk &&
(vehicle_response_result.second)) {
// Get the list of all vehicle available with matching VIN
diag::client::vehicle_info::VehicleInfoMessage::VehicleInfoListResponseType vehicle_response_collection{
vehicle_response_result.second->GetVehicleList()};
if (vehicle_response_result.HasValue()) {
// Get the list of all vehicle available
diag::client::vehicle_info::VehicleInfoMessage::VehicleInfoListResponseType const
vehicle_response_collection{vehicle_response_result.Value()->GetVehicleList()};

// Create an uds message using first vehicle available in the list of response collection
std::string remote_ecu_ip_address{vehicle_response_collection[0].ip_address}; // Remote ECU ip address
std::uint16_t remote_ecu_server_logical_address{vehicle_response_collection[0].logical_address}; // Remote ECU logical address
std::string remote_ecu_ip_address{
vehicle_response_collection[0u].ip_address}; // Remote ECU ip address
std::uint16_t remote_ecu_server_logical_address{
vehicle_response_collection[0u].logical_address}; // Remote ECU logical address

// Create an uds payload 10 01 ( Default Session )
diag::client::uds_message::UdsMessage::ByteVector uds_payload{0x10, 0x01};

diag::client::uds_message::UdsRequestMessagePtr uds_message{
std::make_unique<UdsMessage>(remote_ecu_ip_address, UdsMessage::ByteVector{0x10, 0x01})};
std::make_unique<UdsMessage>(remote_ecu_ip_address, uds_payload)};

// Connect Tester One to remote ECU
diag::client::conversation::DiagClientConversation::ConnectResult connect_result{
diag::client::conversation::DiagClientConversation::ConnectResult const connect_result{
diag_client_conversation.ConnectToDiagServer(remote_ecu_server_logical_address,
uds_message->GetHostIpAddress())};

if(connect_result == diag::client::conversation::DiagClientConversation::ConnectResult::kConnectSuccess) {
if (connect_result ==
diag::client::conversation::DiagClientConversation::ConnectResult::kConnectSuccess) {
// Use Tester One to send the diagnostic message to remote ECU
std::pair<diag::client::conversation::DiagClientConversation::DiagResult,
diag::client::uds_message::UdsResponseMessagePtr>
diag_response{diag_client_conversation.SendDiagnosticRequest(std::move(uds_message))};
diag::client::Result<diag::client::uds_message::UdsResponseMessagePtr,
DiagClientConversation::DiagError> const diag_response{
diag_client_conversation.SendDiagnosticRequest(std::move(uds_message))};

if (diag_response.first == diag::client::conversation::DiagClientConversation::DiagResult::kDiagSuccess) {
std::cout << "diag_client_conversation Total size: " << diag_response.second->GetPayload().size() << std::endl;
if (diag_response.HasValue()) {
std::cout << "diag_client_conversation Total size: "
<< diag_response.Value()->GetPayload().size() << std::endl;
// Print the payload
for (auto const byte: diag_response.second->GetPayload()) {
std::cout << "diag_client_conversation byte: " << std::hex << static_cast<int>(byte) << std::endl;
for (auto const byte: diag_response.Value()->GetPayload()) {
std::cout << "diag_client_conversation byte: " << std::hex << static_cast<int>(byte)
<< std::endl;
}
}
// Disconnect Tester One from ECU1 with remote ip address "172.16.25.128"
// Disconnect Tester One from remote Ecu
diag_client_conversation.DisconnectFromDiagServer();
}
}

// shutdown the conversation
diag_client_conversation.Shutdown();

// important to release all the resources by calling de-initialize
diag_client->DeInitialize();
*/
return (0);
return 0;
}

0 comments on commit 0e9b971

Please sign in to comment.