Diag-Client-Lib
vd_message.cpp
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 */
9 
10 #include <sstream>
11 #include <string_view>
12 
13 namespace diag {
14 namespace client {
15 namespace vd_message {
16 
17 auto SerializeVehicleInfoList(std::uint8_t preselection_mode, uds_transport::ByteVector& preselection_value) noexcept
19  constexpr std::uint8_t VehicleIdentificationHandler{0U};
20 
21  uds_transport::ByteVector payload{VehicleIdentificationHandler, preselection_mode};
22  payload.insert(payload.begin() + 2U, preselection_value.begin(), preselection_value.end());
23  return payload;
24 }
25 
26 VdMessage::VdMessage(std::uint8_t preselection_mode, uds_transport::ByteVector& preselection_value,
27  std::string_view host_ip_address)
28  : uds_transport::UdsMessage(),
29  source_address_{0U},
30  target_address_{0U},
31  target_address_type{TargetAddressType::kPhysical},
32  host_ip_address_{host_ip_address},
33  vehicle_info_payload_{SerializeVehicleInfoList(preselection_mode, preselection_value)} {}
34 
36  : uds_transport::UdsMessage(),
37  source_address_{0U},
38  target_address_{0U},
39  target_address_type{TargetAddressType::kPhysical} {}
40 
41 } // namespace vd_message
42 } // namespace client
43 } // namespace diag
auto SerializeVehicleInfoList(std::uint8_t preselection_mode, uds_transport::ByteVector &preselection_value) noexcept -> uds_transport::ByteVector
Definition: vd_message.cpp:17
std::vector< std::uint8_t > ByteVector