Diag-Client-Lib
vd_message.h
Go to the documentation of this file.
1 /* Diagnostic Client library
2 * Copyright (C) 2024 Avijit Dey
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8 #ifndef DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_SERVICE_VD_MESSAGE_H
9 #define DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_SERVICE_VD_MESSAGE_H
10 /* includes */
14 
15 namespace diag {
16 namespace client {
17 namespace vd_message {
18 
19 class VdMessage final : public uds_transport::UdsMessage {
20  public:
21  // ctor
22  VdMessage(std::uint8_t preselection_mode, uds_transport::ByteVector& preselection_value,
23  std::string_view host_ip_address);
24 
25  // default ctor
26  VdMessage() noexcept;
27 
28  // dtor
29  ~VdMessage() noexcept override = default;
30 
31  private:
32  // SA
34 
35  // TA
37 
38  // TA type
40 
41  // Host Ip Address
43 
44  // store the vehicle info payload
46 
47  // store the
48  std::shared_ptr<const MetaInfoMap> meta_info_{};
49 
50  // add new metaInfo to this message.
51  void AddMetaInfo(std::shared_ptr<const MetaInfoMap> meta_info) override {
52  // update meta info data
53  if (meta_info != nullptr) {
54  meta_info_ = meta_info;
55  host_ip_address_ = meta_info_->at("kRemoteIpAddress");
56  }
57  }
58 
59  // Get the UDS message data starting with the SID (A_Data as per ISO)
60  const uds_transport::ByteVector& GetPayload() const override { return vehicle_info_payload_; }
61 
62  // return the underlying buffer for write access
64 
65  // Get the source address of the uds message.
66  Address GetSa() const noexcept override { return source_address_; }
67 
68  // Get the target address of the uds message.
69  Address GetTa() const noexcept override { return target_address_; }
70 
71  // Get the target address type (phys/func) of the uds message.
72  TargetAddressType GetTaType() const noexcept override { return target_address_type; }
73 
74  // Get Host Ip address
75  IpAddress GetHostIpAddress() const noexcept override { return host_ip_address_; }
76 
77  // Get Host port number
78  PortNumber GetHostPortNumber() const noexcept override { return 13400U; }
79 };
80 
81 } // namespace vd_message
82 } // namespace client
83 } // namespace diag
84 
85 #endif // DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_SERVICE_VD_MESSAGE_H
TargetAddressType GetTaType() const noexcept override
Definition: vd_message.h:72
void AddMetaInfo(std::shared_ptr< const MetaInfoMap > meta_info) override
Definition: vd_message.h:51
Address GetSa() const noexcept override
Definition: vd_message.h:66
uds_transport::ByteVector vehicle_info_payload_
Definition: vd_message.h:45
uds_transport::ByteVector & GetPayload() override
Definition: vd_message.h:63
IpAddress GetHostIpAddress() const noexcept override
Definition: vd_message.h:75
std::shared_ptr< const MetaInfoMap > meta_info_
Definition: vd_message.h:48
const uds_transport::ByteVector & GetPayload() const override
Definition: vd_message.h:60
PortNumber GetHostPortNumber() const noexcept override
Definition: vd_message.h:78
~VdMessage() noexcept override=default
Address GetTa() const noexcept override
Definition: vd_message.h:69
TargetAddressType target_address_type
Definition: vd_message.h:39
std::string_view IpAddress
Definition: uds_message.h:24
std::map< std::string, std::string > MetaInfoMap
Definition: uds_message.h:28
std::uint16_t PortNumber
Definition: uds_message.h:26
std::vector< std::uint8_t > ByteVector