blob: 4e8ca916371c27955f9e4dbc04093d21375533c0 [file] [log] [blame]
Tom Josephbe703f72017-03-09 12:34:35 +05301#pragma once
Patrick Venture0b02be92018-08-31 11:55:55 -07002
Vernon Maueryeeb0f982019-05-29 16:36:58 -07003#include <boost/system/error_code.hpp>
Yong Li7dc4ac02019-08-23 17:44:32 +08004#include <ipmid/api-types.hpp>
Vernon Maueryeeb0f982019-05-29 16:36:58 -07005#include <ipmid/message.hpp>
Vernon Mauery33250242019-03-12 16:49:26 -07006#include <ipmid/types.hpp>
George Liude1420d2025-03-03 15:14:25 +08007#include <phosphor-logging/lg2.hpp>
William A. Kennington IIIe47fdfb2018-03-15 17:09:28 -07008#include <sdbusplus/server.hpp>
Tom Josephbe703f72017-03-09 12:34:35 +05309
Patrick Williamsfbc6c9d2023-05-10 07:50:16 -050010#include <chrono>
11#include <optional>
Prithvi Paic1e7b5c2025-09-01 13:13:15 +053012#include <string>
13#include <vector>
Patrick Williamsfbc6c9d2023-05-10 07:50:16 -050014
Tom Josephbe703f72017-03-09 12:34:35 +053015namespace ipmi
16{
17
Kun Yi5dcf41e2019-03-05 14:02:51 -080018using namespace std::literals::chrono_literals;
19
Ratan Guptacc8feb42017-07-25 21:52:10 +053020constexpr auto MAPPER_BUS_NAME = "xyz.openbmc_project.ObjectMapper";
21constexpr auto MAPPER_OBJ = "/xyz/openbmc_project/object_mapper";
22constexpr auto MAPPER_INTF = "xyz.openbmc_project.ObjectMapper";
23
24constexpr auto ROOT = "/";
25constexpr auto HOST_MATCH = "host0";
Ratan Guptacc8feb42017-07-25 21:52:10 +053026
Ratan Guptab8e99552017-07-27 07:07:48 +053027constexpr auto PROP_INTF = "org.freedesktop.DBus.Properties";
28constexpr auto DELETE_INTERFACE = "xyz.openbmc_project.Object.Delete";
Ratan Guptacc8feb42017-07-25 21:52:10 +053029
30constexpr auto METHOD_GET = "Get";
31constexpr auto METHOD_GET_ALL = "GetAll";
32constexpr auto METHOD_SET = "Set";
33
Kun Yi5dcf41e2019-03-05 14:02:51 -080034/* Use a value of 5s which aligns with BT/KCS bridged timeouts, rather
35 * than the default 25s D-Bus timeout. */
36constexpr std::chrono::microseconds IPMI_DBUS_TIMEOUT = 5s;
37
William A. Kennington IIIe47fdfb2018-03-15 17:09:28 -070038/** @class ServiceCache
39 * @brief Caches lookups of service names from the object mapper.
40 * @details Most ipmi commands need to talk to other dbus daemons to perform
41 * their intended actions on the BMC. This usually means they will
42 * first look up the service name providing the interface they
43 * require. This class reduces the number of such calls by caching
44 * the lookup for a specific service.
45 */
Patrick Venture0b02be92018-08-31 11:55:55 -070046class ServiceCache
47{
48 public:
49 /** @brief Creates a new service cache for the given interface
50 * and path.
51 *
52 * @param[in] intf - The interface used for each lookup
53 * @param[in] path - The path used for each lookup
54 */
55 ServiceCache(const std::string& intf, const std::string& path);
56 ServiceCache(std::string&& intf, std::string&& path);
William A. Kennington IIIe47fdfb2018-03-15 17:09:28 -070057
Patrick Venture0b02be92018-08-31 11:55:55 -070058 /** @brief Gets the service name from the cache or does in a
59 * lookup when invalid.
60 *
61 * @param[in] bus - The bus associated with and used for looking
62 * up the service.
63 */
Patrick Williams5d82f472022-07-22 19:26:53 -050064 const std::string& getService(sdbusplus::bus_t& bus);
William A. Kennington IIIe47fdfb2018-03-15 17:09:28 -070065
Patrick Venture0b02be92018-08-31 11:55:55 -070066 /** @brief Invalidates the current service name */
67 void invalidate();
William A. Kennington IIIe47fdfb2018-03-15 17:09:28 -070068
Patrick Venture0b02be92018-08-31 11:55:55 -070069 /** @brief A wrapper around sdbusplus bus.new_method_call
70 *
71 * @param[in] bus - The bus used for calling the method
72 * @param[in] intf - The interface containing the method
73 * @param[in] method - The method name
74 * @return The message containing the method call.
75 */
Patrick Williams5d82f472022-07-22 19:26:53 -050076 sdbusplus::message_t newMethodCall(sdbusplus::bus_t& bus, const char* intf,
77 const char* method);
William A. Kennington III82c173a2018-05-11 16:10:12 -070078
Patrick Venture0b02be92018-08-31 11:55:55 -070079 /** @brief Check to see if the current cache is valid
80 *
81 * @param[in] bus - The bus used for the service lookup
82 * @return True if the cache is valid false otherwise.
83 */
Patrick Williams5d82f472022-07-22 19:26:53 -050084 bool isValid(sdbusplus::bus_t& bus) const;
Patrick Venture0b02be92018-08-31 11:55:55 -070085
86 private:
87 /** @brief DBUS interface provided by the service */
88 const std::string intf;
89 /** @brief DBUS path provided by the service */
90 const std::string path;
91 /** @brief The name of the service if valid */
Vernon Mauery54012502018-11-07 10:17:31 -080092 std::optional<std::string> cachedService;
Patrick Venture0b02be92018-08-31 11:55:55 -070093 /** @brief The name of the bus used in the service lookup */
Vernon Mauery54012502018-11-07 10:17:31 -080094 std::optional<std::string> cachedBusName;
William A. Kennington IIIe47fdfb2018-03-15 17:09:28 -070095};
96
Tom Josephbe703f72017-03-09 12:34:35 +053097/**
98 * @brief Get the DBUS Service name for the input dbus path
99 *
100 * @param[in] bus - DBUS Bus Object
101 * @param[in] intf - DBUS Interface
102 * @param[in] path - DBUS Object Path
103 *
104 */
Patrick Williams5d82f472022-07-22 19:26:53 -0500105std::string getService(sdbusplus::bus_t& bus, const std::string& intf,
Tom Josephbe703f72017-03-09 12:34:35 +0530106 const std::string& path);
Ratan Guptacc8feb42017-07-25 21:52:10 +0530107
George Liu50f186c2024-02-04 16:51:26 +0800108/** @brief Gets the dbus sub tree implementing the given interface.
109 * @param[in] bus - DBUS Bus Object.
110 * @param[in] interfaces - Dbus interface.
111 * @param[in] subtreePath - subtree from where the search should start.
112 * @param[in] depth - Search depth
113 * @return map of object path and service info.
114 */
115ObjectTree getSubTree(sdbusplus::bus_t& bus, const InterfaceList& interface,
116 const std::string& subtreePath = ROOT, int32_t depth = 0);
117
Ratan Guptacc8feb42017-07-25 21:52:10 +0530118/** @brief Gets the dbus object info implementing the given interface
119 * from the given subtree.
Ratan Gupta01d4bd12017-08-07 15:53:25 +0530120 * @param[in] bus - DBUS Bus Object.
Ratan Guptacc8feb42017-07-25 21:52:10 +0530121 * @param[in] interface - Dbus interface.
122 * @param[in] subtreePath - subtree from where the search should start.
123 * @param[in] match - identifier for object.
124 * @return On success returns the object having objectpath and servicename.
125 */
Patrick Williams1318a5e2024-08-16 15:19:54 -0400126DbusObjectInfo getDbusObject(
127 sdbusplus::bus_t& bus, const std::string& interface,
128 const std::string& subtreePath = ROOT, const std::string& match = {});
Ratan Guptacc8feb42017-07-25 21:52:10 +0530129
130/** @brief Gets the value associated with the given object
131 * and the interface.
Ratan Gupta01d4bd12017-08-07 15:53:25 +0530132 * @param[in] bus - DBUS Bus Object.
Ratan Guptacc8feb42017-07-25 21:52:10 +0530133 * @param[in] service - Dbus service name.
134 * @param[in] objPath - Dbus object path.
135 * @param[in] interface - Dbus interface.
136 * @param[in] property - name of the property.
137 * @return On success returns the value of the property.
138 */
Patrick Williams5d82f472022-07-22 19:26:53 -0500139Value getDbusProperty(sdbusplus::bus_t& bus, const std::string& service,
Patrick Venture0b02be92018-08-31 11:55:55 -0700140 const std::string& objPath, const std::string& interface,
Kun Yi5dcf41e2019-03-05 14:02:51 -0800141 const std::string& property,
142 std::chrono::microseconds timeout = IPMI_DBUS_TIMEOUT);
Ratan Guptacc8feb42017-07-25 21:52:10 +0530143
144/** @brief Gets all the properties associated with the given object
145 * and the interface.
Ratan Gupta01d4bd12017-08-07 15:53:25 +0530146 * @param[in] bus - DBUS Bus Object.
Ratan Guptacc8feb42017-07-25 21:52:10 +0530147 * @param[in] service - Dbus service name.
148 * @param[in] objPath - Dbus object path.
149 * @param[in] interface - Dbus interface.
150 * @return On success returns the map of name value pair.
151 */
Patrick Williams1318a5e2024-08-16 15:19:54 -0400152PropertyMap getAllDbusProperties(
153 sdbusplus::bus_t& bus, const std::string& service,
154 const std::string& objPath, const std::string& interface,
155 std::chrono::microseconds timeout = IPMI_DBUS_TIMEOUT);
Ratan Guptacc8feb42017-07-25 21:52:10 +0530156
Dhruvaraj Subhashchandran5c0beec2018-01-23 04:47:06 -0600157/** @brief Gets all managed objects associated with the given object
158 * path and service.
159 * @param[in] bus - D-Bus Bus Object.
160 * @param[in] service - D-Bus service name.
161 * @param[in] objPath - D-Bus object path.
162 * @return On success returns the map of name value pair.
163 */
Patrick Williams5d82f472022-07-22 19:26:53 -0500164ObjectValueTree getManagedObjects(sdbusplus::bus_t& bus,
Patrick Venture0b02be92018-08-31 11:55:55 -0700165 const std::string& service,
166 const std::string& objPath);
Dhruvaraj Subhashchandran5c0beec2018-01-23 04:47:06 -0600167
Ratan Guptacc8feb42017-07-25 21:52:10 +0530168/** @brief Sets the property value of the given object.
Ratan Gupta01d4bd12017-08-07 15:53:25 +0530169 * @param[in] bus - DBUS Bus Object.
Ratan Guptacc8feb42017-07-25 21:52:10 +0530170 * @param[in] service - Dbus service name.
171 * @param[in] objPath - Dbus object path.
172 * @param[in] interface - Dbus interface.
173 * @param[in] property - name of the property.
174 * @param[in] value - value which needs to be set.
175 */
Patrick Williams5d82f472022-07-22 19:26:53 -0500176void setDbusProperty(sdbusplus::bus_t& bus, const std::string& service,
Patrick Venture0b02be92018-08-31 11:55:55 -0700177 const std::string& objPath, const std::string& interface,
Kun Yi5dcf41e2019-03-05 14:02:51 -0800178 const std::string& property, const Value& value,
179 std::chrono::microseconds timeout = IPMI_DBUS_TIMEOUT);
Ratan Guptacc8feb42017-07-25 21:52:10 +0530180
Ratan Guptab8e99552017-07-27 07:07:48 +0530181/** @brief Gets all the dbus objects from the given service root
182 * which matches the object identifier.
183 * @param[in] bus - DBUS Bus Object.
184 * @param[in] serviceRoot - Service root path.
185 * @param[in] interface - Dbus interface.
186 * @param[in] match - Identifier for a path.
187 * @returns map of object path and service info.
188 */
Patrick Williams1318a5e2024-08-16 15:19:54 -0400189ObjectTree getAllDbusObjects(
190 sdbusplus::bus_t& bus, const std::string& serviceRoot,
191 const std::string& interface, const std::string& match = {});
Ratan Guptab8e99552017-07-27 07:07:48 +0530192
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700193/********* Begin co-routine yielding alternatives ***************/
194
195/** @brief Get the D-Bus Service name for the input D-Bus path
196 *
197 * @param[in] ctx - ipmi::Context::ptr
198 * @param[in] intf - D-Bus Interface
199 * @param[in] path - D-Bus Object Path
200 * @param[out] service - requested service name
201 * @return boost error code
202 *
203 */
Patrick Williams69b4c282025-03-03 11:19:13 -0500204boost::system::error_code getService(Context::ptr ctx, const std::string& intf,
205 const std::string& path,
206 std::string& service);
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700207
George Liu50f186c2024-02-04 16:51:26 +0800208/** @brief Gets the dbus sub tree implementing the given interface.
209 * @param[in] ctx - ipmi::Context::ptr
210 * @param[in] bus - DBUS Bus Object.
211 * @param[in] interfaces - Dbus interface.
212 * @param[in] subtreePath - subtree from where the search should start.
213 * @param[in] depth - Search depth
214 * @param[out] objectTree - map of object path and service info.
215 * @return map of object path and service info.
216 */
Patrick Williams1318a5e2024-08-16 15:19:54 -0400217boost::system::error_code getSubTree(
218 Context::ptr ctx, const InterfaceList& interface,
219 const std::string& subtreePath, int32_t depth, ObjectTree& objectTree);
George Liu50f186c2024-02-04 16:51:26 +0800220
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700221/** @brief Gets the D-Bus object info implementing the given interface
222 * from the given subtree.
223 * @param[in] ctx - ipmi::Context::ptr
224 * @param[in] interface - D-Bus interface.
225 * @param[in][optional] subtreePath - subtree from where the search starts.
226 * @param[in][optional] match - identifier for object.
227 * @param[out] D-Bus object with path and service name
228 * @return - boost error code object
229 */
Patrick Williams69b4c282025-03-03 11:19:13 -0500230boost::system::error_code getDbusObject(
231 Context::ptr ctx, const std::string& interface,
232 const std::string& subtreePath, const std::string& match,
233 DbusObjectInfo& dbusObject);
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700234
235// default for ROOT for subtreePath and std::string{} for match
Patrick Williams1318a5e2024-08-16 15:19:54 -0400236static inline boost::system::error_code getDbusObject(
237 Context::ptr ctx, const std::string& interface, DbusObjectInfo& dbusObject)
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700238{
239 return getDbusObject(ctx, interface, ROOT, {}, dbusObject);
240}
241
242// default std::string{} for match
Patrick Williams69b4c282025-03-03 11:19:13 -0500243static inline boost::system::error_code getDbusObject(
244 Context::ptr ctx, const std::string& interface,
245 const std::string& subtreePath, DbusObjectInfo& dbusObject)
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700246{
247 return getDbusObject(ctx, interface, subtreePath, {}, dbusObject);
248}
249
250/** @brief Gets the value associated with the given object
251 * and the interface.
252 * @param[in] ctx - ipmi::Context::ptr
253 * @param[in] service - D-Bus service name.
254 * @param[in] objPath - D-Bus object path.
255 * @param[in] interface - D-Bus interface.
256 * @param[in] property - name of the property.
257 * @param[out] propertyValue - value of the D-Bus property.
258 * @return - boost error code object
259 */
260template <typename Type>
Patrick Williams69b4c282025-03-03 11:19:13 -0500261boost::system::error_code getDbusProperty(
262 Context::ptr ctx, const std::string& service, const std::string& objPath,
263 const std::string& interface, const std::string& property,
264 Type& propertyValue)
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700265{
266 boost::system::error_code ec;
267 auto variant = ctx->bus->yield_method_call<std::variant<Type>>(
268 ctx->yield, ec, service.c_str(), objPath.c_str(), PROP_INTF, METHOD_GET,
269 interface, property);
270 if (!ec)
271 {
272 Type* tmp = std::get_if<Type>(&variant);
273 if (tmp)
274 {
275 propertyValue = *tmp;
276 return ec;
277 }
278 // user requested incorrect type; make an error code for them
279 ec = boost::system::errc::make_error_code(
280 boost::system::errc::invalid_argument);
281 }
282 return ec;
283}
284
285/** @brief Gets all the properties associated with the given object
286 * and the interface.
287 * @param[in] ctx - ipmi::Context::ptr
288 * @param[in] service - D-Bus service name.
289 * @param[in] objPath - D-Bus object path.
290 * @param[in] interface - D-Bus interface.
291 * @param[out] properties - map of name value pair.
292 * @return - boost error code object
293 */
Patrick Williams1318a5e2024-08-16 15:19:54 -0400294boost::system::error_code getAllDbusProperties(
295 Context::ptr ctx, const std::string& service, const std::string& objPath,
296 const std::string& interface, PropertyMap& properties);
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700297
298/** @brief Sets the property value of the given object.
299 * @param[in] ctx - ipmi::Context::ptr
300 * @param[in] service - D-Bus service name.
301 * @param[in] objPath - D-Bus object path.
302 * @param[in] interface - D-Bus interface.
303 * @param[in] property - name of the property.
304 * @param[in] value - value which needs to be set.
305 * @return - boost error code object
306 */
Patrick Williams69b4c282025-03-03 11:19:13 -0500307boost::system::error_code setDbusProperty(
308 Context::ptr ctx, const std::string& service, const std::string& objPath,
309 const std::string& interface, const std::string& property,
310 const Value& value);
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700311
312/** @brief Gets all the D-Bus objects from the given service root
313 * which matches the object identifier.
314 * @param[in] ctx - ipmi::Context::ptr
315 * @param[in] serviceRoot - Service root path.
316 * @param[in] interface - D-Bus interface.
317 * @param[in][optional] match - Identifier for a path.
318 * @param[out] objectree - map of object path and service info.
319 * @return - boost error code object
320 */
Patrick Williams69b4c282025-03-03 11:19:13 -0500321boost::system::error_code getAllDbusObjects(
322 Context::ptr ctx, const std::string& serviceRoot,
323 const std::string& interface, const std::string& match,
324 ObjectTree& objectTree);
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700325
326// default std::string{} for match
Patrick Williams69b4c282025-03-03 11:19:13 -0500327static inline boost::system::error_code getAllDbusObjects(
328 Context::ptr ctx, const std::string& serviceRoot,
329 const std::string& interface, ObjectTree& objectTree)
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700330{
331 return getAllDbusObjects(ctx, serviceRoot, interface, {}, objectTree);
332}
333
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700334/** @brief Gets all managed objects associated with the given object
335 * path and service.
336 * @param[in] ctx - ipmi::Context::ptr
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700337 * @param[in] service - D-Bus service name.
338 * @param[in] objPath - D-Bus object path.
Vernon Maueryfe39ec92020-03-02 13:58:41 -0800339 * @param[out] objects - map of name value pair.
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700340 * @return - boost error code object
341 */
Patrick Williams69b4c282025-03-03 11:19:13 -0500342boost::system::error_code getManagedObjects(
343 Context::ptr ctx, const std::string& service, const std::string& objPath,
344 ObjectValueTree& objects);
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700345
Albert Zhangb53049e2022-04-02 15:39:51 +0800346/** @brief Gets the value associated with the given object
347 * and the interface.
348 * @param[in] ctx - ipmi::Context::ptr
349 * @param[in] service - D-Bus service name.
350 * @param[in] objPath - D-Bus object path.
351 * @param[in] interface - D-Bus interface.
352 * @param[in] method - name of the method.
353 * @return - boost error code object
354 */
355
Patrick Williams1318a5e2024-08-16 15:19:54 -0400356boost::system::error_code callDbusMethod(
357 Context::ptr ctx, const std::string& service, const std::string& objPath,
358 const std::string& interface, const std::string& method);
Albert Zhangb53049e2022-04-02 15:39:51 +0800359
Vernon Maueryeeb0f982019-05-29 16:36:58 -0700360/********* End co-routine yielding alternatives ***************/
361
Vernon Mauerye7e8b812019-10-28 16:00:34 -0700362/** @brief Retrieve the value from map of variants,
363 * returning a default if the key does not exist or the
364 * type of the value does not match the expected type
365 *
366 * @tparam T - type of expected value to return
367 * @param[in] props - D-Bus propery map (Map of variants)
368 * @param[in] name - key name of property to fetch
369 * @param[in] defaultValue - default value to return on error
370 * @return - value from propery map at name, or defaultValue
371 */
372template <typename T>
373T mappedVariant(const ipmi::PropertyMap& props, const std::string& name,
374 const T& defaultValue)
375{
376 auto item = props.find(name);
377 if (item == props.end())
378 {
379 return defaultValue;
380 }
381 const T* prop = std::get_if<T>(&item->second);
382 if (!prop)
383 {
384 return defaultValue;
385 }
386 return *prop;
387}
388
James Feist1e121122018-07-31 11:44:09 -0700389/** @struct VariantToDoubleVisitor
390 * @brief Visitor to convert variants to doubles
391 * @details Performs a static cast on the underlying type
392 */
393struct VariantToDoubleVisitor
394{
395 template <typename T>
Patrick Williams69b4c282025-03-03 11:19:13 -0500396 std::enable_if_t<std::is_arithmetic<T>::value, double> operator()(
397 const T& t) const
James Feist1e121122018-07-31 11:44:09 -0700398 {
399 return static_cast<double>(t);
400 }
401
402 template <typename T>
Patrick Williams69b4c282025-03-03 11:19:13 -0500403 std::enable_if_t<!std::is_arithmetic<T>::value, double> operator()(
404 const T&) const
James Feist1e121122018-07-31 11:44:09 -0700405 {
406 throw std::invalid_argument("Cannot translate type to double");
407 }
408};
409
Ratan Guptab8e99552017-07-27 07:07:48 +0530410namespace method_no_args
411{
412
413/** @brief Calls the Dbus method which waits for response.
414 * @param[in] bus - DBUS Bus Object.
415 * @param[in] service - Dbus service name.
416 * @param[in] objPath - Dbus object path.
417 * @param[in] interface - Dbus interface.
418 * @param[in] method - Dbus method.
419 */
Patrick Williams5d82f472022-07-22 19:26:53 -0500420void callDbusMethod(sdbusplus::bus_t& bus, const std::string& service,
Patrick Venture0b02be92018-08-31 11:55:55 -0700421 const std::string& objPath, const std::string& interface,
Ratan Guptab8e99552017-07-27 07:07:48 +0530422 const std::string& method);
423
Patrick Venture0b02be92018-08-31 11:55:55 -0700424} // namespace method_no_args
Ratan Guptab8e99552017-07-27 07:07:48 +0530425
George Liude1420d2025-03-03 15:14:25 +0800426template <typename... InputArgs>
427boost::system::error_code callDbusMethod(
428 ipmi::Context::ptr ctx, const std::string& service,
429 const std::string& objPath, const std::string& interface,
430 const std::string& method, const InputArgs&... args)
431{
432 boost::system::error_code ec;
433 ctx->bus->yield_method_call(ctx->yield, ec, service, objPath, interface,
434 method, args...);
435
436 return ec;
437}
438
439template <typename RetType, typename... InputArgs>
440RetType callDbusMethod(ipmi::Context::ptr ctx, boost::system::error_code& ec,
441 const std::string& service, const std::string& objPath,
442 const std::string& interface, const std::string& method,
443 const InputArgs&... args)
444{
445 auto rc = ctx->bus->yield_method_call<RetType>(
446 ctx->yield, ec, service, objPath, interface, method, args...);
447
448 return rc;
449}
450
Yong Li7dc4ac02019-08-23 17:44:32 +0800451/** @brief Perform the low-level i2c bus write-read.
452 * @param[in] i2cBus - i2c bus device node name, such as /dev/i2c-2.
Matt Simmering68d9d402023-11-09 14:22:11 -0800453 * @param[in] targetAddr - i2c device target address.
Yong Li7dc4ac02019-08-23 17:44:32 +0800454 * @param[in] writeData - The data written to i2c device.
455 * @param[out] readBuf - Data read from the i2c device.
456 */
Matt Simmering68d9d402023-11-09 14:22:11 -0800457ipmi::Cc i2cWriteRead(std::string i2cBus, const uint8_t targetAddr,
Yong Li7dc4ac02019-08-23 17:44:32 +0800458 std::vector<uint8_t> writeData,
459 std::vector<uint8_t>& readBuf);
Prithvi Paic1e7b5c2025-09-01 13:13:15 +0530460
461/** @brief Split a string into a vector of strings
462 * @param[in] srcStr - The string to split
463 * @param[in] delim - The delimiter to split the string on
464 * @return A vector of strings
465 */
466std::vector<std::string> split(const std::string& srcStr, char delim);
467
Tom Josephbe703f72017-03-09 12:34:35 +0530468} // namespace ipmi