Diag-Client-Lib
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
diag::client::conversation::DiagClientConversation Class Referencefinal

Conversation class to establish connection with a Diagnostic Server. More...

#include <diagnostic_client_conversation.h>

Classes

class  DiagClientConversationImpl
 

Public Types

enum class  ConnectResult : std::uint8_t { kConnectSuccess = 0U , kConnectFailed = 1U , kConnectTimeout = 2U }
 Definitions of Connection results. More...
 
enum class  DisconnectResult : std::uint8_t { kDisconnectSuccess = 0U , kDisconnectFailed = 1U , kAlreadyDisconnected = 2U }
 Definitions of Disconnection results. More...
 
enum class  DiagError : std::uint8_t {
  kDiagGenericFailure = 1U , kDiagRequestSendFailed = 2U , kDiagAckTimeout = 3U , kDiagNegAckReceived = 4U ,
  kDiagResponseTimeout = 5U , kDiagInvalidParameter = 6U , kDiagBusyProcessing = 7U
}
 Definitions of Diagnostics Request Response results. More...
 
using IpAddress = uds_message::UdsMessage::IpAddress
 Type alias of ip address type. More...
 

Public Member Functions

 DiagClientConversation (std::string_view conversation_name) noexcept
 Constructor an instance of DiagClientConversation. More...
 
 ~DiagClientConversation () noexcept
 Destructor an instance of DiagClientConversation -Conversation-Destruction. More...
 
void Startup () noexcept
 Function to startup the Diagnostic Client Conversation. More...
 
void Shutdown () noexcept
 Function to shutdown the Diagnostic Client Conversation. More...
 
ConnectResult ConnectToDiagServer (std::uint16_t target_address, IpAddress host_ip_addr) noexcept
 Function to connect to Diagnostic Server using Target address and IP address of the server. More...
 
DisconnectResult DisconnectFromDiagServer () noexcept
 Function to disconnect from Diagnostic Server. More...
 
Result< uds_message::UdsResponseMessagePtr, DiagErrorSendDiagnosticRequest (uds_message::UdsRequestMessageConstPtr message) noexcept
 Function to send Diagnostic Request and get Diagnostic Response. More...
 

Private Attributes

std::unique_ptr< DiagClientConversationImpldiag_client_conversation_impl_
 Unique pointer to diag client conversation implementation. More...
 

Detailed Description

Conversation class to establish connection with a Diagnostic Server.

This only support DoIP communication protocol for diagnostic communication with remote Diagnostic Server

Definition at line 24 of file diagnostic_client_conversation.h.

Member Typedef Documentation

◆ IpAddress

Type alias of ip address type.

Definition at line 29 of file diagnostic_client_conversation.h.

Member Enumeration Documentation

◆ ConnectResult

Definitions of Connection results.

Enumerator
kConnectSuccess 

Successfully connected to Diagnostic Server

kConnectFailed 

Connection failure to Diagnostic Server, check logs for more failure information

kConnectTimeout 

No Connection response received from Diagnostic Server

Definition at line 35 of file diagnostic_client_conversation.h.

35  : std::uint8_t {
36  kConnectSuccess = 0U,
37  kConnectFailed = 1U,
38  kConnectTimeout = 2U
39  };

◆ DiagError

Definitions of Diagnostics Request Response results.

Enumerator
kDiagGenericFailure 

Generic Diagnostic Error, see logs for more information

kDiagRequestSendFailed 

Diagnostic request message transmission failure

kDiagAckTimeout 

No diagnostic acknowledgement response received within 2 seconds

kDiagNegAckReceived 

Diagnostic negative acknowledgement received

kDiagResponseTimeout 

No diagnostic response message received within P2/P2Star time

kDiagInvalidParameter 

Passed parameter value is not valid

kDiagBusyProcessing 

Conversation is already busy processing previous request

Definition at line 53 of file diagnostic_client_conversation.h.

53  : std::uint8_t {
54  kDiagGenericFailure = 1U,
55  kDiagRequestSendFailed = 2U,
56  kDiagAckTimeout = 3U,
57  kDiagNegAckReceived = 4U,
58  kDiagResponseTimeout = 5U,
59  kDiagInvalidParameter = 6U,
60  kDiagBusyProcessing = 7U
61  };

◆ DisconnectResult

Definitions of Disconnection results.

Enumerator
kDisconnectSuccess 

Successfully disconnected from Diagnostic Server

kDisconnectFailed 

Disconnection failure with Diagnostic Server, check logs for more information

kAlreadyDisconnected 

Not connected to Diagnostic Server

Definition at line 44 of file diagnostic_client_conversation.h.

44  : std::uint8_t {
45  kDisconnectSuccess = 0U,
46  kDisconnectFailed = 1U,
47  kAlreadyDisconnected = 2U
48  };

Constructor & Destructor Documentation

◆ DiagClientConversation()

diag::client::conversation::DiagClientConversation::DiagClientConversation ( std::string_view  conversation_name)
explicitnoexcept

Constructor an instance of DiagClientConversation.

Parameters
[in]conversation_nameThe name of conversation configured as json parameter under "ConversationName" -Conversation-Construction, DiagClientLib-DoIP-Support

Definition at line 88 of file diagnostic_client_conversation.cpp.

89  : diag_client_conversation_impl_{std::make_unique<DiagClientConversationImpl>(conversation_name)} {}
std::unique_ptr< DiagClientConversationImpl > diag_client_conversation_impl_
Unique pointer to diag client conversation implementation.

◆ ~DiagClientConversation()

diag::client::conversation::DiagClientConversation::~DiagClientConversation ( )
defaultnoexcept

Destructor an instance of DiagClientConversation -Conversation-Destruction.

Member Function Documentation

◆ ConnectToDiagServer()

DiagClientConversation::ConnectResult diag::client::conversation::DiagClientConversation::ConnectToDiagServer ( std::uint16_t  target_address,
DiagClientConversation::IpAddress  host_ip_addr 
)
noexcept

Function to connect to Diagnostic Server using Target address and IP address of the server.

This will try to initiate a TCP connection with Server and then send DoIP Routing Activation request

Parameters
[in]target_addressLogical address of the Remote server
[in]host_ip_addrIP address of the Remote server
Returns
ConnectResult Connection result returned -Conversation-Connect

Definition at line 97 of file diagnostic_client_conversation.cpp.

98  {
99  return diag_client_conversation_impl_->ConnectToDiagServer(target_address, host_ip_addr);
100 }

◆ DisconnectFromDiagServer()

DiagClientConversation::DisconnectResult diag::client::conversation::DiagClientConversation::DisconnectFromDiagServer ( )
noexcept

Function to disconnect from Diagnostic Server.

This will close the existing TCP connection with Server and reset Routing Activation state

Returns
DisconnectResult Disconnection result returned -Conversation-Disconnect

Definition at line 102 of file diagnostic_client_conversation.cpp.

102  {
103  return diag_client_conversation_impl_->DisconnectFromDiagServer();
104 }

References diag_client_conversation_impl_.

◆ SendDiagnosticRequest()

Result< uds_message::UdsResponseMessagePtr, DiagClientConversation::DiagError > diag::client::conversation::DiagClientConversation::SendDiagnosticRequest ( uds_message::UdsRequestMessageConstPtr  message)
noexcept

Function to send Diagnostic Request and get Diagnostic Response.

This is a blocking function i.e. function call either returns with final diagnostic response (Positive/Negative) or with error. It also handles reception of pending response(NRC 0x78) internally within this function call

Parameters
[in]messageThe diagnostic request message wrapped in a unique pointer
Returns
DiagResult The result returned
uds_message::UdsResponseMessagePtr Diagnostic Response message received, DiagError in case of error -Conversation-DiagRequestResponse

Definition at line 107 of file diagnostic_client_conversation.cpp.

107  {
108  return diag_client_conversation_impl_->SendDiagnosticRequest(std::move(message));
109 }

◆ Shutdown()

void diag::client::conversation::DiagClientConversation::Shutdown ( )
noexcept

Function to shutdown the Diagnostic Client Conversation.

Must be called during shutdown phase, no further processing of any function will be allowed after this call -Conversation-Shutdown

Definition at line 95 of file diagnostic_client_conversation.cpp.

95 { diag_client_conversation_impl_->Shutdown(); }

References diag_client_conversation_impl_.

◆ Startup()

void diag::client::conversation::DiagClientConversation::Startup ( )
noexcept

Function to startup the Diagnostic Client Conversation.

Must be called once and before using any other functions of DiagClientConversation -Conversation-StartUp

Definition at line 93 of file diagnostic_client_conversation.cpp.

93 { diag_client_conversation_impl_->Startup(); }

References Startup().

Referenced by Startup().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ diag_client_conversation_impl_

std::unique_ptr<DiagClientConversationImpl> diag::client::conversation::DiagClientConversation::diag_client_conversation_impl_
private

Unique pointer to diag client conversation implementation.

Definition at line 138 of file diagnostic_client_conversation.h.

Referenced by DisconnectFromDiagServer(), and Shutdown().


The documentation for this class was generated from the following files: