sysfs.hpp (431d26a58b89b88492a0dc5c87d3d9e8de49ade1) | sysfs.hpp (8b574a7eecd288f5342779cdf4aa20d640cbe141) |
---|---|
1#pragma once 2 3#include <exception> 4#include <fstream> 5#include <string> 6 7namespace sysfs { 8 --- 102 unchanged lines hidden (view full) --- 111 */ 112uint64_t writeSysfsWithCallout(const uint64_t& value, 113 const std::string& root, 114 const std::string& instance, 115 const std::string& type, 116 const std::string& id, 117 const std::string& sensor); 118 | 1#pragma once 2 3#include <exception> 4#include <fstream> 5#include <string> 6 7namespace sysfs { 8 --- 102 unchanged lines hidden (view full) --- 111 */ 112uint64_t writeSysfsWithCallout(const uint64_t& value, 113 const std::string& root, 114 const std::string& instance, 115 const std::string& type, 116 const std::string& id, 117 const std::string& sensor); 118 |
119namespace hwmonio 120{ 121 122/** @class HwmonIO 123 * @brief Convenience wrappers for HWMON sysfs attribute IO. 124 * 125 * Unburden the rest of the application from having to check 126 * ENOENT after every hwmon attribute io operation. Hwmon 127 * device drivers can be unbound at any time; the program 128 * cannot always be terminated externally before we try to 129 * do an io. 130 */ 131class HwmonIO 132{ 133 public: 134 HwmonIO() = delete; 135 HwmonIO(const HwmonIO&) = default; 136 HwmonIO(HwmonIO&&) = default; 137 HwmonIO& operator=(const HwmonIO&) = default; 138 HwmonIO& operator=(HwmonIO&&) = default; 139 ~HwmonIO() = default; 140 141 /** @brief Constructor 142 * 143 * @param[in] path - hwmon instance root - eg: 144 * /sys/class/hwmon/hwmon<N> 145 */ 146 explicit HwmonIO(const std::string& path); 147 148 /** @brief Perform formatted hwmon sysfs read. 149 * 150 * Propogates any exceptions other than ENOENT. 151 * ENOENT will result in a call to exit(0) in case 152 * the underlying hwmon driver is unbound and 153 * the program is inadvertently left running. 154 * 155 * @param[in] type - The hwmon type (ex. temp). 156 * @param[in] id - The hwmon id (ex. 1). 157 * @param[in] sensor - The hwmon sensor (ex. input). 158 * 159 * @return val - The read value. 160 */ 161 uint32_t read( 162 const std::string& type, 163 const std::string& id, 164 const std::string& sensor) const; 165 166 /** @brief Perform formatted hwmon sysfs write. 167 * 168 * Propogates any exceptions other than ENOENT. 169 * ENOENT will result in a call to exit(0) in case 170 * the underlying hwmon driver is unbound and 171 * the program is inadvertently left running. 172 * 173 * @param[in] val - The value to be written. 174 * @param[in] type - The hwmon type (ex. fan). 175 * @param[in] id - The hwmon id (ex. 1). 176 * @param[in] sensor - The hwmon sensor (ex. target). 177 */ 178 void write( 179 uint32_t val, 180 const std::string& type, 181 const std::string& id, 182 const std::string& sensor) const; 183 184 /** @brief Hwmon instance path access. 185 * 186 * @return path - The hwmon instance path. 187 */ 188 std::string path() const; 189 190 private: 191 std::string p; 192}; 193} // namespace hwmonio |
|
119} 120 121// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 | 194} 195 196// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 |