blob: 3635ea1c49fc67043fe36f25b4e530361c9640ef [file] [log] [blame]
Lei YU0ab90ca2017-07-13 17:02:23 +08001#pragma once
2
3#include <experimental/filesystem>
4#include <vector>
5
6#ifdef I2C_OCC
7
8namespace i2c_occ
9{
10
11namespace fs = std::experimental::filesystem;
12
13/** @brief Get file content
14 *
15 * Get at most NAME_LENGTH bytes of content from file. If the file is smaller
16 * than NAME_LENGTH bytes, return the valid parts.
17 *
18 * @param[in] f - The path of file
19 *
20 * @return The string of file content
21 */
22std::string getFileContent(const fs::path& f);
23
24/** @brief Find all devices of occ hwmon
25 *
26 * It iterates in path, finds all occ hwmon devices
27 *
28 * E.g. If "path/3-0050/name" exists and its content is "p8-occ-hwmon",
29 * "3-0050" is returned.
30 *
31 * @param[in] path - The path to search
32 *
33 * @return A vector of strings containing the occ hwmon device path
Lei YU41470e52017-11-30 16:03:50 +080034 where the first device is master occ
Lei YU0ab90ca2017-07-13 17:02:23 +080035 */
36std::vector<std::string> getOccHwmonDevices(const char* path);
37
38/** @brief Convert i2c name to DBus path
39 *
40 * It converts '-' to '_' so that it becomes a valid DBus path.
41 * E.g. 3-0050 converts to 3_0050
42 *
43 * @param[in,out] path - The i2c name to convert
44 */
45void i2cToDbus(std::string& name);
46
47/** @brief Convert DBus path to i2c name
48 *
49 * It converts '_' to '_' so that it becomes a valid i2c name
50 * E.g. 3_0050 converts to 3-0050
51 *
52 * @param[in,out] path - The DBus path to convert
53 */
54void dbusToI2c(std::string& path);
55
56/** @brief Get i2c name from full DBus path
57 *
58 * It extract the i2c name from the full DBus path.
59 * E.g. /org/open_power/control/3_0050 returns "3-0050"
60 *
61 * @param[in] dbusPath - The full DBus path
62 *
63 * @return The i2c name
64 */
65std::string getI2cDeviceName(const std::string& dbusPath);
66
67} // namespace i2c_occ
68
69#endif