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

Class to establish connection with Diagnostic Server. More...

#include <dm_conversation.h>

Inheritance diagram for diag::client::conversation::DmConversation:
Inheritance graph
[legend]
Collaboration diagram for diag::client::conversation::DmConversation:
Collaboration graph
[legend]

Public Types

using ConversationState = conversation_state_impl::ConversationState
 Type alias for conversation internal state. More...
 
using SyncTimer = utility::sync_timer::SyncTimer< std::chrono::steady_clock >
 Type alias for synchronous timer. More...
 
- Public Types inherited from diag::client::conversation::Conversation
using IpAddress = DiagClientConversation::IpAddress
 Type alias for Ip address. More...
 
using ConnectResult = DiagClientConversation::ConnectResult
 Type alias for Connection results. More...
 
using DisconnectResult = DiagClientConversation::DisconnectResult
 Type alias for Disconnection results. More...
 
using DiagError = DiagClientConversation::DiagError
 Type alias for Diagnostic results. More...
 

Public Member Functions

 DmConversation (std::string_view conversion_name, DMConversationType &conversion_identifier)
 Constructs an instance of DmConversation. More...
 
 DmConversation (const DmConversation &other) noexcept=delete
 Deleted copy assignment and copy constructor. More...
 
DmConversationoperator= (const DmConversation &other) noexcept=delete
 
 DmConversation (DmConversation &&other) noexcept=delete
 Deleted move assignment and move constructor. More...
 
DmConversationoperator= (DmConversation &&other) noexcept=delete
 
 ~DmConversation () override
 Destructs an instance of DmConversation. More...
 
void Startup () noexcept override
 Function to start the DmConversation. More...
 
void Shutdown () noexcept override
 Function to shutdown the DmConversation. More...
 
void RegisterConnection (std::unique_ptr<::uds_transport::Connection > connection) noexcept override
 Function to register the conversation to underlying transport protocol handler. More...
 
::uds_transport::ConversionHandlerGetConversationHandler () noexcept override
 Function to get the conversation handler from conversation object. More...
 
ConnectResult ConnectToDiagServer (std::uint16_t target_address, IpAddress host_ip_addr) noexcept override
 Function to connect to Diagnostic Server. More...
 
DisconnectResult DisconnectFromDiagServer () noexcept override
 Function to disconnect from Diagnostic Server. More...
 
std::pair<::uds_transport::UdsTransportProtocolMgr::IndicationResult, ::uds_transport::UdsMessagePtrIndicateMessage (::uds_transport::UdsMessage::Address source_addr, ::uds_transport::UdsMessage::Address target_addr, ::uds_transport::UdsMessage::TargetAddressType type, ::uds_transport::ChannelID channel_id, std::size_t size, ::uds_transport::Priority priority, ::uds_transport::ProtocolKind protocol_kind, core_type::Span< std::uint8_t > payload_info) noexcept override
 Function to indicate a start of reception of message. More...
 
void HandleMessage (::uds_transport::UdsMessagePtr message) noexcept override
 Function to Hands over a valid received Uds message. More...
 
Result< uds_message::UdsResponseMessagePtr, DiagErrorSendDiagnosticRequest (uds_message::UdsRequestMessageConstPtr message) noexcept override
 Function to send Diagnostic Request and get Diagnostic Response. More...
 
- Public Member Functions inherited from diag::client::conversation::Conversation
 Conversation () noexcept=default
 Constructs an instance of Conversation. More...
 
 Conversation (const Conversation &other) noexcept=delete
 Deleted copy assignment and copy constructor. More...
 
Conversationoperator= (const Conversation &other) noexcept=delete
 
 Conversation (Conversation &&other) noexcept=delete
 Deleted move assignment and move constructor. More...
 
Conversationoperator= (Conversation &&other) noexcept=delete
 
virtual ~Conversation () noexcept=default
 Destructs an instance of Conversation. More...
 
virtual core_type::Result< diag::client::vehicle_info::VehicleInfoMessageResponseUniquePtr, DiagClient::VehicleInfoResponseErrorSendVehicleIdentificationRequest (vehicle_info::VehicleInfoListRequestType) noexcept
 Function to send vehicle identification request and get the Diagnostic Server list. More...
 

Private Types

enum class  SessionControlType : std::uint8_t { kDefaultSession = 0x01 , kProgrammingSession = 0x02 , kExtendedSession = 0x03 , kSystemSafetySession = 0x04 }
 Definitions of active diagnostic session. More...
 
enum class  SecurityLevelType : std::uint8_t { kLocked = 0x00 , kUnLocked = 0x01 }
 Definitions of active security level. More...
 
enum class  ActivityStatusType : uint8_t { kActive = 0x00 , kInactive = 0x01 }
 Definitions of current activity status. More...
 

Static Private Member Functions

static DiagClientConversation::DiagError ConvertResponseType (::uds_transport::UdsTransportProtocolMgr::TransmissionResult result_type)
 Helper function to convert response type. More...
 

Private Attributes

ActivityStatusType activity_status_
 Store the conversation activity status. More...
 
SessionControlType active_session_
 Store the active diagnostic session. More...
 
SecurityLevelType active_security_level_
 Store the active diagnostic security level. More...
 
std::uint32_t rx_buffer_size_
 Store the size of reception buffer size setting. More...
 
std::uint16_t p2_client_max_
 Store the maximum p2 client time. More...
 
std::uint16_t p2_star_client_max_
 Store the maximum p2 star client time. More...
 
std::uint16_t source_address_
 Store the logical source address of conversation. More...
 
std::uint16_t target_address_
 Store the logical target address of remote server. More...
 
std::string remote_address_
 Store the remote IP address of remote server. More...
 
std::string conversation_name_
 Store the conversation name. More...
 
std::unique_ptr<::uds_transport::ConversionHandlerdm_conversion_handler_
 Store the dm conversation handler. More...
 
std::unique_ptr<::uds_transport::Connectionconnection_ptr_
 Store the underlying transport protocol connection object. More...
 
SyncTimer sync_timer_
 Store the synchronous timer. More...
 
::uds_transport::ByteVector payload_rx_buffer_
 Store the received uds response. More...
 
conversation_state_impl::ConversationStateImpl conversation_state_
 Store the conversation state. More...
 

Detailed Description

Class to establish connection with Diagnostic Server.

Definition at line 28 of file dm_conversation.h.

Member Typedef Documentation

◆ ConversationState

Type alias for conversation internal state.

Definition at line 33 of file dm_conversation.h.

◆ SyncTimer

Type alias for synchronous timer.

Definition at line 37 of file dm_conversation.h.

Member Enumeration Documentation

◆ ActivityStatusType

Definitions of current activity status.

Enumerator
kActive 
kInactive 

Definition at line 180 of file dm_conversation.h.

180 : uint8_t { kActive = 0x00, kInactive = 0x01 };

◆ SecurityLevelType

Definitions of active security level.

Enumerator
kLocked 
kUnLocked 

Definition at line 172 of file dm_conversation.h.

172  : std::uint8_t {
173  kLocked = 0x00,
174  kUnLocked = 0x01,
175  };

◆ SessionControlType

Definitions of active diagnostic session.

Enumerator
kDefaultSession 
kProgrammingSession 
kExtendedSession 
kSystemSafetySession 

Definition at line 162 of file dm_conversation.h.

162  : std::uint8_t {
163  kDefaultSession = 0x01,
164  kProgrammingSession = 0x02,
165  kExtendedSession = 0x03,
166  kSystemSafetySession = 0x04
167  };

Constructor & Destructor Documentation

◆ DmConversation() [1/3]

diag::client::conversation::DmConversation::DmConversation ( std::string_view  conversion_name,
DMConversationType conversion_identifier 
)

Constructs an instance of DmConversation.

Parameters
[in]conversion_nameThe name of conversation
[in]conversion_identifierThe identifier consisting of conversation settings

Definition at line 105 of file dm_conversation.cpp.

106  : Conversation{},
110  rx_buffer_size_{conversion_identifier.rx_buffer_size},
111  p2_client_max_{conversion_identifier.p2_client_max},
112  p2_star_client_max_{conversion_identifier.p2_star_client_max},
113  source_address_{conversion_identifier.source_address},
114  target_address_{},
115  conversation_name_{conversion_name},
116  dm_conversion_handler_{std::make_unique<DmConversationHandler>(conversion_identifier.handler_id, *this)} {
117  (void) (active_session_);
118  (void) (active_security_level_);
119 }
Conversation() noexcept=default
Constructs an instance of Conversation.
std::uint16_t p2_client_max_
Store the maximum p2 client time.
std::unique_ptr<::uds_transport::ConversionHandler > dm_conversion_handler_
Store the dm conversation handler.
std::uint32_t rx_buffer_size_
Store the size of reception buffer size setting.
std::uint16_t p2_star_client_max_
Store the maximum p2 star client time.
ActivityStatusType activity_status_
Store the conversation activity status.
SessionControlType active_session_
Store the active diagnostic session.
std::uint16_t target_address_
Store the logical target address of remote server.
SecurityLevelType active_security_level_
Store the active diagnostic security level.
std::uint16_t source_address_
Store the logical source address of conversation.
std::string conversation_name_
Store the conversation name.

References active_security_level_, and active_session_.

◆ DmConversation() [2/3]

diag::client::conversation::DmConversation::DmConversation ( const DmConversation other)
deletenoexcept

Deleted copy assignment and copy constructor.

◆ DmConversation() [3/3]

diag::client::conversation::DmConversation::DmConversation ( DmConversation &&  other)
deletenoexcept

Deleted move assignment and move constructor.

◆ ~DmConversation()

diag::client::conversation::DmConversation::~DmConversation ( )
overridedefault

Destructs an instance of DmConversation.

Member Function Documentation

◆ ConnectToDiagServer()

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

Function to connect to Diagnostic Server.

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

Reimplemented from diag::client::conversation::Conversation.

Definition at line 151 of file dm_conversation.cpp.

152  {
153  // create an uds message just to get the port number
154  // source address required for Routing Activation
155  uds_transport::ByteVector payload{}; // empty payload
156  // Send Connect request to doip layer
158  connection_ptr_->ConnectToHost(std::make_unique<diag::client::uds_message::DmUdsMessage>(
159  source_address_, target_address, host_ip_addr, payload)))};
160  remote_address_ = host_ip_addr;
161  target_address_ = target_address;
163  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogInfo(
164  __FILE__, __LINE__, __func__, [this](std::stringstream &msg) {
165  msg << "'" << conversation_name_ << "'"
166  << "-> "
167  << "Successfully connected to Server with IP <" << remote_address_ << ">"
168  << " and LA= 0x" << std::hex << target_address_;
169  });
170  } else {
171  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogError(
172  __FILE__, __LINE__, __func__, [this](std::stringstream &msg) {
173  msg << "'" << conversation_name_ << "'"
174  << "-> "
175  << "Failed connecting to Server with IP <" << remote_address_ << ">"
176  << " and LA= 0x" << std::hex << target_address_;
177  });
178  }
179  return connection_result;
180 }
std::string remote_address_
Store the remote IP address of remote server.
std::unique_ptr<::uds_transport::Connection > connection_ptr_
Store the underlying transport protocol connection object.
static auto GetDiagClientLogger() noexcept -> DiagClientLogger &
Get the diag client logger instance.
Definition: logger.h:32
std::vector< std::uint8_t > ByteVector

References diag::client::logger::DiagClientLogger::GetDiagClientLogger(), and diag::client::conversation::DiagClientConversation::kConnectSuccess.

Here is the call graph for this function:

◆ ConvertResponseType()

DiagClientConversation::DiagError diag::client::conversation::DmConversation::ConvertResponseType ( ::uds_transport::UdsTransportProtocolMgr::TransmissionResult  result_type)
staticprivate

Helper function to convert response type.

Parameters
[in]result_typeThe transmission result type
Returns
DiagResult The diagnostic result type

Definition at line 394 of file dm_conversation.cpp.

395  {
397  switch (result_type) {
400  break;
403  break;
406  break;
409  break;
410  default:
412  break;
413  }
414  return ret_result;
415 }
DiagError
Definitions of Diagnostics Request Response results.

References uds_transport::UdsTransportProtocolMgr::kBusyProcessing, diag::client::conversation::DiagClientConversation::kDiagAckTimeout, diag::client::conversation::DiagClientConversation::kDiagBusyProcessing, diag::client::conversation::DiagClientConversation::kDiagGenericFailure, diag::client::conversation::DiagClientConversation::kDiagNegAckReceived, diag::client::conversation::DiagClientConversation::kDiagRequestSendFailed, uds_transport::UdsTransportProtocolMgr::kNegTransmitAckReceived, uds_transport::UdsTransportProtocolMgr::kNoTransmitAckReceived, and uds_transport::UdsTransportProtocolMgr::kTransmitFailed.

◆ DisconnectFromDiagServer()

DiagClientConversation::DisconnectResult diag::client::conversation::DmConversation::DisconnectFromDiagServer ( )
overridevirtualnoexcept

Function to disconnect from Diagnostic Server.

Returns
DisconnectResult Disconnection result returned

Reimplemented from diag::client::conversation::Conversation.

Definition at line 182 of file dm_conversation.cpp.

182  {
184  // Check if already connected before disconnecting
185  if (connection_ptr_->IsConnectToHost()) {
186  // Send disconnect request to doip layer
187  ret_val = static_cast<DiagClientConversation::DisconnectResult>(connection_ptr_->DisconnectFromHost());
189  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogInfo(
190  __FILE__, __LINE__, __func__, [this](std::stringstream &msg) {
191  msg << "'" << conversation_name_ << "'"
192  << "-> "
193  << "Successfully disconnected from Server with IP <" << remote_address_ << ">"
194  << " and LA= 0x" << std::hex << target_address_;
195  });
196  } else {
197  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogWarn(
198  __FILE__, __LINE__, __func__, [&](std::stringstream &msg) {
199  msg << "'" << conversation_name_ << "'"
200  << "-> "
201  << "Failed to disconnect from Server with IP <" << remote_address_ << ">";
202  });
203  }
204  } else {
206  }
207  return ret_val;
208 }

References connection_ptr_, conversation_name_, diag::client::logger::DiagClientLogger::GetDiagClientLogger(), diag::client::conversation::DiagClientConversation::kAlreadyDisconnected, diag::client::conversation::DiagClientConversation::kDisconnectFailed, diag::client::conversation::DiagClientConversation::kDisconnectSuccess, remote_address_, and target_address_.

Here is the call graph for this function:

◆ GetConversationHandler()

uds_transport::ConversionHandler & diag::client::conversation::DmConversation::GetConversationHandler ( )
overridevirtualnoexcept

Function to get the conversation handler from conversation object.

Returns
ConversionHandler & The reference to conversation handler

Implements diag::client::conversation::Conversation.

Definition at line 326 of file dm_conversation.cpp.

326  {
327  return *dm_conversion_handler_;
328 }

References dm_conversion_handler_.

◆ HandleMessage()

void diag::client::conversation::DmConversation::HandleMessage ( ::uds_transport::UdsMessagePtr  message)
overridevirtualnoexcept

Function to Hands over a valid received Uds message.

Parameters
[in]messageThe The Uds message ptr (unique_ptr semantics) with the request. Ownership of the UdsMessage is given back to the conversation here

Implements diag::client::conversation::Conversation.

Definition at line 388 of file dm_conversation.cpp.

388  {
389  if (message != nullptr) {
391  }
392 }
conversation_state_impl::ConversationStateImpl conversation_state_
Store the conversation state.
auto GetConversationStateContext() noexcept -> StateContext< ConversationState > &

Referenced by diag::client::conversation::DmConversationHandler::HandleMessage().

Here is the caller graph for this function:

◆ IndicateMessage()

std::pair< uds_transport::UdsTransportProtocolMgr::IndicationResult, uds_transport::UdsMessagePtr > diag::client::conversation::DmConversation::IndicateMessage ( ::uds_transport::UdsMessage::Address  source_addr,
::uds_transport::UdsMessage::Address  target_addr,
::uds_transport::UdsMessage::TargetAddressType  type,
::uds_transport::ChannelID  channel_id,
std::size_t  size,
::uds_transport::Priority  priority,
::uds_transport::ProtocolKind  protocol_kind,
core_type::Span< std::uint8_t >  payload_info 
)
overridevirtualnoexcept

Function to indicate a start of reception of message.

This is called to indicate the reception of new message by underlying transport protocol handler

Parameters
[in]source_addrThe UDS source address of message
[in]target_addrThe UDS target address of message
[in]typeThe indication whether its is phys/func request
[in]channel_idThe transport protocol channel on which message start happened
[in]sizeThe size in bytes of the UdsMessage starting from SID
[in]priorityThe priority of the given message, used for prioritization of conversations
[in]protocol_kindThe identifier of protocol kind associated to message
[in]payload_infoThe View onto the first received payload bytes, if any. This view shall be used only within this function call. It is recommended that the TP provides at least the first two bytes of the request message, so the DM can identify a functional TesterPresent
Returns
std::pair< IndicationResult, UdsMessagePtr > The pair of IndicationResult and a pointer to UdsMessage owned/created by DM core and returned to the handler to get filled

Implements diag::client::conversation::Conversation.

Definition at line 331 of file dm_conversation.cpp.

334  {
335  std::pair<uds_transport::UdsTransportProtocolMgr::IndicationResult, uds_transport::UdsMessagePtr> ret_val{
337  // Verify the payload received :-
338  if (!payload_info.empty()) {
339  // Check for size, else kIndicationOverflow
340  if (size <= rx_buffer_size_) {
341  // Check for pending response
342  // payload = 0x7F XX 0x78
343  if (payload_info[0U] == 0x7F && payload_info[2U] == 0x78) {
344  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogInfo(
345  __FILE__, __LINE__, "", [&](std::stringstream &msg) {
346  msg << "'" << conversation_name_ << "'"
347  << "-> "
348  << "Diagnostic pending response received in Conversation";
349  });
352  } else {
353  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogDebug(
354  __FILE__, __LINE__, "", [this](std::stringstream &msg) {
355  msg << "'" << conversation_name_ << "'"
356  << "-> "
357  << "Diagnostic final response received in Conversation";
358  });
359  // positive or negative response, provide valid buffer
360  // resize the global rx buffer
361  payload_rx_buffer_.resize(size);
363  ret_val.second = std::make_unique<diag::client::uds_message::DmUdsMessage>(source_address_, target_address_, "",
366  }
368  } else {
369  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogError(
370  __FILE__, __LINE__, "", [&](std::stringstream &msg) {
371  msg << "'" << conversation_name_ << "'"
372  << "-> "
373  << "Diagnostic Conversation Error Indication Overflow";
374  });
376  }
377  } else {
378  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogError(
379  __FILE__, __LINE__, "", [&](std::stringstream &msg) {
380  msg << "'" << conversation_name_ << "'"
381  << "-> "
382  << "Diagnostic Conversation Rx Payload size 0 received";
383  });
384  }
385  return ret_val;
386 }
constexpr bool empty() const noexcept
Return whether this Span is empty.
Definition: span.h:520
::uds_transport::ByteVector payload_rx_buffer_
Store the received uds response.
SyncTimer sync_timer_
Store the synchronous timer.
void CancelWait()
Function to cancel the synchronous wait.
Definition: sync_timer.h:90

References diag::client::logger::DiagClientLogger::GetDiagClientLogger(), uds_transport::UdsTransportProtocolMgr::kIndicationNOk, uds_transport::UdsTransportProtocolMgr::kIndicationOk, uds_transport::UdsTransportProtocolMgr::kIndicationOverflow, and uds_transport::UdsTransportProtocolMgr::kIndicationPending.

Referenced by diag::client::conversation::DmConversationHandler::IndicateMessage().

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

◆ operator=() [1/2]

DmConversation& diag::client::conversation::DmConversation::operator= ( const DmConversation other)
deletenoexcept

◆ operator=() [2/2]

DmConversation& diag::client::conversation::DmConversation::operator= ( DmConversation &&  other)
deletenoexcept

◆ RegisterConnection()

void diag::client::conversation::DmConversation::RegisterConnection ( std::unique_ptr<::uds_transport::Connection connection)
overridevirtualnoexcept

Function to register the conversation to underlying transport protocol handler.

Parameters
[in]connectionThe conversation connection object

Implements diag::client::conversation::Conversation.

Definition at line 322 of file dm_conversation.cpp.

322  {
323  connection_ptr_ = std::move(connection);
324 }

◆ SendDiagnosticRequest()

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

Function to send Diagnostic Request and get Diagnostic Response.

Parameters
[in]messageThe diagnostic request message wrapped in a unique pointer
Returns
DiagResult The Result returned
uds_message::UdsResponseMessagePtr Diagnostic Response message received, null_ptr in case of error

Reimplemented from diag::client::conversation::Conversation.

Definition at line 210 of file dm_conversation.cpp.

211  {
212  Result<uds_message::UdsResponseMessagePtr, DiagClientConversation::DiagError> result{
215  if (message) {
216  // fill the data
217  uds_transport::ByteVector payload{message->GetPayload()};
218  // Initiate Sending of diagnostic request
220  connection_ptr_->Transmit(std::make_unique<diag::client::uds_message::DmUdsMessage>(
221  source_address_, target_address_, message->GetHostIpAddress(), payload))};
223  // Diagnostic Request Sent successful
224  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogInfo(
225  __FILE__, __LINE__, __func__, [&](std::stringstream &msg) {
226  msg << "'" << conversation_name_ << "'"
227  << "-> "
228  << "Diagnostic Request Sent & Positive Ack received";
229  });
231  // Wait P6Max / P2ClientMax
233  [this, &result]() {
236  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogInfo(
237  __FILE__, __LINE__, "", [&](std::stringstream &msg) {
238  msg << "'" << conversation_name_ << "'"
239  << "-> "
240  << "Diagnostic Response P2 Timeout happened after " << p2_client_max_ << " milliseconds";
241  });
242  },
243  [this]() {
244  // pending or pos/neg response
245  if (conversation_state_.GetConversationStateContext().GetActiveState().GetState() ==
247  // pos/neg response received
248  } else if (conversation_state_.GetConversationStateContext().GetActiveState().GetState() ==
250  // first pending received
252  }
253  },
254  std::chrono::milliseconds{p2_client_max_});
255 
256  // Wait until final response or timeout
257  while (conversation_state_.GetConversationStateContext().GetActiveState().GetState() !=
259  // Check the active state
260  switch (conversation_state_.GetConversationStateContext().GetActiveState().GetState()) {
263  break;
265  // do nothing
266  break;
268  // wait P6Star/ P2 star client time
270  [this, &result]() {
271  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogInfo(
272  __FILE__, __LINE__, "", [&](std::stringstream &msg) {
273  msg << "'" << conversation_name_ << "'"
274  << "-> "
275  << "Diagnostic Response P2 Star Timeout happened after " << p2_star_client_max_
276  << " milliseconds";
277  ;
278  });
281  },
282  [this]() {
283  // pending or pos/neg response
284  if (conversation_state_.GetConversationStateContext().GetActiveState().GetState() ==
286  // pos/neg response received
287  } else if (conversation_state_.GetConversationStateContext().GetActiveState().GetState() ==
289  // pending received again
292  }
293  },
294  std::chrono::milliseconds{p2_star_client_max_});
295  break;
297  // change state to idle, form the uds response and return
298  result.EmplaceValue(std::make_unique<diag::client::uds_message::DmUdsResponse>(payload_rx_buffer_));
300  break;
301  default:
302  // nothing
303  break;
304  }
305  }
306  } else {
307  // failure
308  result.EmplaceError(ConvertResponseType(transmission_result));
309  }
310  } else {
312  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogWarn(__FILE__, __LINE__, "",
313  [&](std::stringstream &msg) {
314  msg << "'" << conversation_name_ << "'"
315  << "-> "
316  << "Diagnostic Request message is empty";
317  });
318  }
319  return result;
320 }
static Result FromError(const E &e) noexcept
Build a new Result from the specified error (given as lvalue)
Definition: result.h:83
static DiagClientConversation::DiagError ConvertResponseType(::uds_transport::UdsTransportProtocolMgr::TransmissionResult result_type)
Helper function to convert response type.
void WaitForTimeout(TimeoutCallback &&timeout_func, CancelCallback &&cancellation_func, std::chrono::milliseconds const timeout)
Helper function to wait for response with timeout monitoring.
Definition: sync_timer.h:70

References core_type::Result< T, E >::FromError(), diag::client::logger::DiagClientLogger::GetDiagClientLogger(), diag::client::conversation::DiagClientConversation::kDiagInvalidParameter, diag::client::conversation::DiagClientConversation::kDiagRequestSendFailed, diag::client::conversation::DiagClientConversation::kDiagResponseTimeout, and uds_transport::UdsTransportProtocolMgr::kTransmitOk.

Here is the call graph for this function:

◆ Shutdown()

void diag::client::conversation::DmConversation::Shutdown ( )
overridevirtualnoexcept

Function to shutdown the DmConversation.

Implements diag::client::conversation::Conversation.

Definition at line 138 of file dm_conversation.cpp.

138  {
139  // shutdown connection
140  connection_ptr_->Stop();
141  // Change the state to InActive
143  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogInfo(__FILE__, __LINE__, __func__,
144  [&](std::stringstream &msg) {
145  msg << "'" << conversation_name_ << "'"
146  << "-> "
147  << "Shutdown completed";
148  });
149 }

References activity_status_, connection_ptr_, conversation_name_, diag::client::logger::DiagClientLogger::GetDiagClientLogger(), and kInactive.

Here is the call graph for this function:

◆ Startup()

void diag::client::conversation::DmConversation::Startup ( )
overridevirtualnoexcept

Function to start the DmConversation.

Implements diag::client::conversation::Conversation.

Definition at line 123 of file dm_conversation.cpp.

123  {
124  // initialize the connection
125  connection_ptr_->Initialize();
126  // start the connection
127  connection_ptr_->Start();
128  // Change the state to Active
130  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogInfo(__FILE__, __LINE__, __func__,
131  [&](std::stringstream &msg) {
132  msg << "'" << conversation_name_ << "'"
133  << "-> "
134  << "Startup completed";
135  });
136 }

References activity_status_, connection_ptr_, conversation_name_, diag::client::logger::DiagClientLogger::GetDiagClientLogger(), and kActive.

Here is the call graph for this function:

Member Data Documentation

◆ active_security_level_

SecurityLevelType diag::client::conversation::DmConversation::active_security_level_
private

Store the active diagnostic security level.

Definition at line 206 of file dm_conversation.h.

Referenced by DmConversation().

◆ active_session_

SessionControlType diag::client::conversation::DmConversation::active_session_
private

Store the active diagnostic session.

Definition at line 201 of file dm_conversation.h.

Referenced by DmConversation().

◆ activity_status_

ActivityStatusType diag::client::conversation::DmConversation::activity_status_
private

Store the conversation activity status.

Definition at line 196 of file dm_conversation.h.

Referenced by Shutdown(), and Startup().

◆ connection_ptr_

std::unique_ptr<::uds_transport::Connection> diag::client::conversation::DmConversation::connection_ptr_
private

Store the underlying transport protocol connection object.

Definition at line 251 of file dm_conversation.h.

Referenced by DisconnectFromDiagServer(), Shutdown(), and Startup().

◆ conversation_name_

std::string diag::client::conversation::DmConversation::conversation_name_
private

Store the conversation name.

Definition at line 241 of file dm_conversation.h.

Referenced by DisconnectFromDiagServer(), Shutdown(), and Startup().

◆ conversation_state_

conversation_state_impl::ConversationStateImpl diag::client::conversation::DmConversation::conversation_state_
private

Store the conversation state.

Definition at line 266 of file dm_conversation.h.

◆ dm_conversion_handler_

std::unique_ptr<::uds_transport::ConversionHandler> diag::client::conversation::DmConversation::dm_conversion_handler_
private

Store the dm conversation handler.

Definition at line 246 of file dm_conversation.h.

Referenced by GetConversationHandler().

◆ p2_client_max_

std::uint16_t diag::client::conversation::DmConversation::p2_client_max_
private

Store the maximum p2 client time.

Definition at line 216 of file dm_conversation.h.

◆ p2_star_client_max_

std::uint16_t diag::client::conversation::DmConversation::p2_star_client_max_
private

Store the maximum p2 star client time.

Definition at line 221 of file dm_conversation.h.

◆ payload_rx_buffer_

::uds_transport::ByteVector diag::client::conversation::DmConversation::payload_rx_buffer_
private

Store the received uds response.

Definition at line 261 of file dm_conversation.h.

◆ remote_address_

std::string diag::client::conversation::DmConversation::remote_address_
private

Store the remote IP address of remote server.

Definition at line 236 of file dm_conversation.h.

Referenced by DisconnectFromDiagServer().

◆ rx_buffer_size_

std::uint32_t diag::client::conversation::DmConversation::rx_buffer_size_
private

Store the size of reception buffer size setting.

Definition at line 211 of file dm_conversation.h.

◆ source_address_

std::uint16_t diag::client::conversation::DmConversation::source_address_
private

Store the logical source address of conversation.

Definition at line 226 of file dm_conversation.h.

◆ sync_timer_

SyncTimer diag::client::conversation::DmConversation::sync_timer_
private

Store the synchronous timer.

Definition at line 256 of file dm_conversation.h.

◆ target_address_

std::uint16_t diag::client::conversation::DmConversation::target_address_
private

Store the logical target address of remote server.

Definition at line 231 of file dm_conversation.h.

Referenced by DisconnectFromDiagServer().


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