1 #pragma once
2 
3 #include <experimental/filesystem>
4 #include <vector>
5 
6 #ifdef I2C_OCC
7 
8 namespace i2c_occ
9 {
10 
11 namespace 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  */
22 std::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
34  */
35 std::vector<std::string> getOccHwmonDevices(const char* path);
36 
37 /** @brief Convert i2c name to DBus path
38  *
39  * It converts '-' to '_' so that it becomes a valid DBus path.
40  * E.g. 3-0050 converts to 3_0050
41  *
42  * @param[in,out] path - The i2c name to convert
43  */
44 void i2cToDbus(std::string& name);
45 
46 /** @brief Convert DBus path to i2c name
47  *
48  * It converts '_' to '_' so that it becomes a valid i2c name
49  * E.g. 3_0050 converts to 3-0050
50  *
51  * @param[in,out] path - The DBus path to convert
52  */
53 void dbusToI2c(std::string& path);
54 
55 /** @brief Get i2c name from full DBus path
56  *
57  * It extract the i2c name from the full DBus path.
58  * E.g. /org/open_power/control/3_0050 returns "3-0050"
59  *
60  * @param[in] dbusPath - The full DBus path
61  *
62  * @return The i2c name
63  */
64 std::string getI2cDeviceName(const std::string& dbusPath);
65 
66 } // namespace i2c_occ
67 
68 #endif
69 
70