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