Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows fixes, boost deprecations, FF protocol for VIR #49

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Diagnostic Client library
* Copyright (C) 2024 Avijit Dey
*
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
Expand Down Expand Up @@ -28,6 +28,11 @@ class DiagClientConversation final {
*/
using IpAddress = uds_message::UdsMessage::IpAddress;

/**
* @brief Type alias for DoIP protocol version
*/
using DoIpProtocol = std::uint8_t;

public:
/**
* @brief Definitions of Connection results
Expand Down Expand Up @@ -127,6 +132,18 @@ class DiagClientConversation final {
*/
DisconnectResult DisconnectFromDiagServer() noexcept;

/**
* @brief Function to get currently used DoIP protocol version
* @return DoIpProtocol
* Version of DoIP protocol used for messages
*/
DoIpProtocol GetDoIpProtocol() const noexcept;

/**
* @brief Function to set DoIP protocol version for messages
*/
void SetDoIpProtocol(DoIpProtocol protocol) noexcept;

/**
* @brief Function to send Diagnostic Request and get Diagnostic Response
* @details This is a blocking function i.e. function call either returns with final diagnostic response (Positive/Negative)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ struct VehicleAddrInfoResponse {
* Bytes are separated by a “:”-character
*/
std::string gid{};

/**
* @brief Version of DoIP protocol used by vehicle
*/
std::uint8_t doip_protocol_version{};
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class Conversation {
*/
using DiagError = DiagClientConversation::DiagError;

/**
* @brief Type alias for DoIP protocol version
*/
using DoIpProtocol = DiagClientConversation::DoIpProtocol;


/**
* @brief Definitions of current activity status
*/
Expand Down Expand Up @@ -118,6 +124,18 @@ class Conversation {
return DisconnectResult::kDisconnectFailed;
}

/**
* @brief Function to set DoIP protocol version for messages
*/
virtual void SetDoIpProtocol(DoIpProtocol version) noexcept = 0;

/**
* @brief Function to get used DoIP protocol version
* @return DoIpProtocol
* Currently used protool version
*/
virtual DoIpProtocol GetDoIpProtocol() const noexcept = 0;

/**
* @brief Function to indicate a start of reception of message
* @details This is called to indicate the reception of new message by underlying transport protocol handler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Diagnostic Client library
* Copyright (C) 2024 Avijit Dey
*
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
Expand Down Expand Up @@ -115,6 +115,7 @@ DmConversation::DmConversation(std::string_view conversion_name,
source_address_{conversion_identifier.source_address},
target_address_{},
conversation_name_{conversion_name},
protocol_ver_{doip_client::kDoip_ProtocolVersion},
dm_conversion_handler_{
std::make_unique<DmConversationHandler>(conversion_identifier.handler_id, *this)} {}

Expand Down Expand Up @@ -159,7 +160,7 @@ DiagClientConversation::ConnectResult DmConversation::ConnectToDiagServer(
DiagClientConversation::ConnectResult const connection_result{
static_cast<DiagClientConversation::ConnectResult>(
connection_->ConnectToHost(std::make_unique<diag::client::uds_message::DmUdsMessage>(
source_address_, target_address, host_ip_addr, payload)))};
protocol_ver_, source_address_, target_address, host_ip_addr, payload)))};
remote_address_ = host_ip_addr;
target_address_ = target_address;
if (connection_result == DiagClientConversation::ConnectResult::kConnectSuccess) {
Expand Down Expand Up @@ -223,7 +224,8 @@ DmConversation::SendDiagnosticRequest(uds_message::UdsRequestMessageConstPtr mes
// Initiate Sending of diagnostic request
uds_transport::UdsTransportProtocolMgr::TransmissionResult const transmission_result{
connection_->Transmit(std::make_unique<diag::client::uds_message::DmUdsMessage>(
source_address_, target_address_, message->GetHostIpAddress(), payload))};
protocol_ver_, source_address_, target_address_, message->GetHostIpAddress(),
payload))};
if (transmission_result ==
uds_transport::UdsTransportProtocolMgr::TransmissionResult::kTransmitOk) {
// Diagnostic Request Sent successful
Expand Down Expand Up @@ -345,6 +347,12 @@ ::uds_transport::ConversionHandler &DmConversation::GetConversationHandler() noe
return *dm_conversion_handler_;
}

void DmConversation::SetDoIpProtocol(DoIpProtocol version) noexcept { protocol_ver_ = version; }

Conversation::DoIpProtocol DmConversation::GetDoIpProtocol() const noexcept {
return protocol_ver_;
}

std::pair<uds_transport::UdsTransportProtocolMgr::IndicationResult, uds_transport::UdsMessagePtr>
DmConversation::IndicateMessage(uds_transport::UdsMessage::Address,
uds_transport::UdsMessage::Address,
Expand Down Expand Up @@ -383,7 +391,7 @@ DmConversation::IndicateMessage(uds_transport::UdsMessage::Address,
payload_rx_buffer_.resize(size);
ret_val.first = uds_transport::UdsTransportProtocolMgr::IndicationResult::kIndicationOk;
ret_val.second = std::make_unique<diag::client::uds_message::DmUdsMessage>(
source_address_, target_address_, "", payload_rx_buffer_);
protocol_ver_, source_address_, target_address_, "", payload_rx_buffer_);
conversation_state_.GetConversationStateContext().TransitionTo(
ConversationState::kDiagRecvdFinalRes);
}
Expand Down Expand Up @@ -440,4 +448,4 @@ DiagClientConversation::DiagError DmConversation::ConvertResponseType(

} // namespace conversation
} // namespace client
} // namespace diag
} // namespace diag
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Diagnostic Client library
* Copyright (C) 2024 Avijit Dey
*
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
Expand Down Expand Up @@ -107,6 +107,18 @@ class DmConversation final : public Conversation {
*/
DisconnectResult DisconnectFromDiagServer() noexcept override;

/**
* @brief Function to set DoIP protocol version for messages
*/
void SetDoIpProtocol(DoIpProtocol version) noexcept override;

/**
* @brief Function to get used DoIP protocol version
* @return DoIpProtocol
* Currently used protool version
*/
DoIpProtocol GetDoIpProtocol() const noexcept override;

/**
* @brief Function to indicate a start of reception of message
* @details This is called to indicate the reception of new message by underlying transport protocol handler
Expand Down Expand Up @@ -236,6 +248,11 @@ class DmConversation final : public Conversation {
*/
std::string conversation_name_;

/**
* @brief Store the DoIP protocol version for messages
*/
DoIpProtocol protocol_ver_;

/**
* @brief Store the dm conversation handler
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ VdConversation::VdConversation(std::string_view conversion_name,
: vd_conversion_handler_{std::make_unique<VdConversationHandler>(
conversion_identifier.handler_id, *this)},
conversation_name_{conversion_name},
protocol_ver_{doip_client::kDoip_ProtocolVersion},
broadcast_address_{conversion_identifier.udp_broadcast_address},
connection_ptr_{},
vehicle_info_collection_{},
Expand Down Expand Up @@ -364,7 +365,8 @@ VdConversation::DeserializeVehicleInfoResponse(uds_transport::UdsMessagePtr mess
logical_address, // logical address
vehicle_info_data_vin, // vin
vehicle_info_data_eid, // eid
vehicle_info_data_gid}; // gid
vehicle_info_data_gid, // gid
message->GetProtocolVersion()}; // protocol

return std::pair<std::uint16_t, VdConversation::VehicleAddrInfoResponseStruct>{logical_address,
vehicle_addr_info};
Expand All @@ -374,6 +376,12 @@ ::uds_transport::ConversionHandler &VdConversation::GetConversationHandler() noe
return *vd_conversion_handler_;
}

void VdConversation::SetDoIpProtocol(DoIpProtocol version) noexcept { protocol_ver_ = version; }

Conversation::DoIpProtocol VdConversation::GetDoIpProtocol() const noexcept {
return protocol_ver_;
}

std::pair<VdConversation::PreselectionMode, VdConversation::PreselectionValue>
VdConversation::DeserializeVehicleInfoRequest(
vehicle_info::VehicleInfoListRequestType &vehicle_info_request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ class VdConversation final : public Conversation {
*/
::uds_transport::ConversionHandler &GetConversationHandler() noexcept override;

/**
* @brief Function to set DoIP protocol version for messages
*/
void SetDoIpProtocol(DoIpProtocol version) noexcept override;

/**
* @brief Function to get used DoIP protocol version
* @return DoIpProtocol
* Currently used protool version
*/
DoIpProtocol GetDoIpProtocol() const noexcept override;

/**
* @brief Function to indicate a start of reception of message
* @details This is called to indicate the reception of new message by underlying transport protocol handler
Expand Down Expand Up @@ -203,6 +215,11 @@ class VdConversation final : public Conversation {
*/
std::string conversation_name_;

/**
* @brief Store the DoIP protocol version for messages
*/
DoIpProtocol protocol_ver_;

/**
* @brief Store the broadcast Ip address of the conversation
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Diagnostic Client library
* Copyright (C) 2024 Avijit Dey
*
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
Expand All @@ -10,17 +10,18 @@
namespace diag {
namespace client {
namespace uds_message {
DmUdsMessage::DmUdsMessage(Address sa, Address ta, IpAddress host_ip_address,
DmUdsMessage::DmUdsMessage(Protocol prot, Address sa, Address ta, IpAddress host_ip_address,
uds_transport::ByteVector &payload)
: uds_transport::UdsMessage(),
source_address_{sa},
target_address_{ta},
target_address_type_{TargetAddressType::kPhysical},
host_ip_address_{host_ip_address},
protocol_ver_{prot},
uds_payload_{payload} {}

DmUdsResponse::DmUdsResponse(ByteVector &payload) : uds_payload_{payload} {}

} // namespace uds_message
} // namespace client
} // namespace diag
} // namespace diag
28 changes: 23 additions & 5 deletions diag-client-lib/appl/src/diag-client/dcm/service/dm_uds_message.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/* Diagnostic Client library
* Copyright (C) 2024 Avijit Dey
*
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_SERVICE_DM_UDS_MESSAGE_H
#define DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_SERVICE_DM_UDS_MESSAGE_H
/* includes */
#include "common/common_doip_types.h"
#include "diag-client/diagnostic_client_uds_message_type.h"
#include "diag-client/diagnostic_client_vehicle_info_message_type.h"
#include "uds_transport/uds_message.h"
Expand All @@ -19,7 +20,7 @@ namespace uds_message {
class DmUdsMessage final : public uds_transport::UdsMessage {
public:
// ctor
DmUdsMessage(Address sa, Address ta, IpAddress host_ip_address,
DmUdsMessage(Protocol prot, Address sa, Address ta, IpAddress host_ip_address,
uds_transport::ByteVector &payload);

// dtor
Expand All @@ -41,9 +42,23 @@ class DmUdsMessage final : public uds_transport::UdsMessage {
// store only UDS payload to be sent
uds_transport::ByteVector &uds_payload_;

// Protocol version
Protocol protocol_ver_ {doip_client::kDoip_ProtocolVersion};

// store the MetaInfo
std::shared_ptr<const MetaInfoMap> meta_info_{};

// add new metaInfo to this message.
void AddMetaInfo(std::shared_ptr<const MetaInfoMap>) override {
// Todo [Add meta info information]
void AddMetaInfo(std::shared_ptr<const MetaInfoMap> meta_info) override {
// update meta info data
if (meta_info != nullptr) {
meta_info_ = meta_info;

std::string str_ver = meta_info_->at("kDoipVersion");
if (!str_ver.empty()) {
protocol_ver_ = std::stoi(str_ver);
}
}
}

// Get the UDS message data starting with the SID (A_Data as per ISO)
Expand All @@ -65,7 +80,10 @@ class DmUdsMessage final : public uds_transport::UdsMessage {
IpAddress GetHostIpAddress() const noexcept override { return host_ip_address_; }

// Get Host port number
PortNumber GetHostPortNumber() const noexcept override { return 13400U; }
PortNumber GetHostPortNumber() const noexcept override { return doip_client::kDoipPort; }

// Get DoIP protocol version
Protocol GetProtocolVersion() const noexcept override { return protocol_ver_; }
};

class DmUdsResponse final : public UdsMessage {
Expand Down
16 changes: 14 additions & 2 deletions diag-client-lib/appl/src/diag-client/dcm/service/vd_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#ifndef DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_SERVICE_VD_MESSAGE_H
#define DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_SERVICE_VD_MESSAGE_H
/* includes */
#include "common/common_doip_types.h"
#include "diag-client/diagnostic_client_uds_message_type.h"
#include "diag-client/diagnostic_client_vehicle_info_message_type.h"
#include "uds_transport/uds_message.h"
Expand Down Expand Up @@ -44,15 +45,23 @@ class VdMessage final : public uds_transport::UdsMessage {
// store the vehicle info payload
uds_transport::ByteVector vehicle_info_payload_;

// store the
// store the MetaInfo
std::shared_ptr<const MetaInfoMap> meta_info_{};

// Protocol version
Protocol protocol_ver_{doip_client::kDoip_ProtocolVersion};

// add new metaInfo to this message.
void AddMetaInfo(std::shared_ptr<const MetaInfoMap> meta_info) override {
// update meta info data
if (meta_info != nullptr) {
meta_info_ = meta_info;
host_ip_address_ = meta_info_->at("kRemoteIpAddress");

std::string str_ver = meta_info_->at("kDoipVersion");
if (!str_ver.empty()) {
protocol_ver_ = std::stoi(str_ver);
}
}
}

Expand All @@ -75,7 +84,10 @@ class VdMessage final : public uds_transport::UdsMessage {
IpAddress GetHostIpAddress() const noexcept override { return host_ip_address_; }

// Get Host port number
PortNumber GetHostPortNumber() const noexcept override { return 13400U; }
PortNumber GetHostPortNumber() const noexcept override { return doip_client::kDoipPort; }

// Get DoIP protocol version
Protocol GetProtocolVersion() const noexcept override { return protocol_ver_; }
};

} // namespace vd_message
Expand Down
Loading