Brad Bishop | 26b815f | 2017-01-04 13:32:47 -0500 | [diff] [blame] | 1 | #pragma once |
Patrick Williams | 3667cf3 | 2015-10-20 22:39:11 -0500 | [diff] [blame] | 2 | |
| 3 | #include <fstream> |
| 4 | #include <string> |
| 5 | |
Brad Bishop | a9b5f05 | 2017-01-17 14:50:08 -0500 | [diff] [blame] | 6 | inline std::string make_sysfs_path(const std::string& path, |
| 7 | const std::string& type, |
| 8 | const std::string& id, |
| 9 | const std::string& entry) |
Patrick Williams | 3667cf3 | 2015-10-20 22:39:11 -0500 | [diff] [blame] | 10 | { |
| 11 | using namespace std::literals; |
| 12 | |
| 13 | return path + "/"s + type + id + "_"s + entry; |
| 14 | } |
| 15 | |
Brad Bishop | 613a5b3 | 2017-01-05 20:58:13 -0500 | [diff] [blame] | 16 | |
| 17 | /** @brief Find hwmon instances |
| 18 | * |
| 19 | * Look for a matching hwmon instance given an |
| 20 | * open firmware device path. |
| 21 | * |
| 22 | * @param[in] ofNode- The open firmware device path. |
| 23 | * |
| 24 | * @returns[in] - The hwmon instance path or an empty |
| 25 | * string if no match is found. |
| 26 | */ |
| 27 | std::string findHwmon(const std::string& ofNode); |
| 28 | |
Brad Bishop | 4db6442 | 2017-02-16 11:33:32 -0500 | [diff] [blame] | 29 | /** @brief Read an hwmon sysfs value. |
| 30 | * |
| 31 | * Calls exit(3) with bad status on failure. |
| 32 | * |
| 33 | * @param[in] root - The hwmon class root. |
| 34 | * @param[in] instance - The hwmon instance (ex. hwmon1). |
| 35 | * @param[in] type - The hwmon type (ex. temp). |
| 36 | * @param[in] id - The hwmon id (ex. 1). |
| 37 | * @param[in] sensor - The hwmon sensor (ex. input). |
| 38 | * |
| 39 | * @returns - The read value. |
| 40 | */ |
| 41 | int readSysfsWithCallout(const std::string& root, |
| 42 | const std::string& instance, |
| 43 | const std::string& type, |
| 44 | const std::string& id, |
| 45 | const std::string& sensor); |
| 46 | |
Brad Bishop | 03476f1 | 2016-12-19 13:09:12 -0500 | [diff] [blame] | 47 | // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 |