diff options
| author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-02-16 11:33:32 -0500 |
|---|---|---|
| committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-03-01 11:33:02 -0500 |
| commit | 4db64422217b51b4f392521568fbcb30dc56a3e9 (patch) | |
| tree | 900c1fcb9b62fe012cfe06c5b8f6b476d694af24 /mainloop.cpp | |
| parent | b8740fc75ec54ff2d37f75f207f9d49f30bf7b1a (diff) | |
| download | phosphor-hwmon-4db64422217b51b4f392521568fbcb30dc56a3e9.tar.gz phosphor-hwmon-4db64422217b51b4f392521568fbcb30dc56a3e9.zip | |
Log failing path after sysfs access failures
Log failing device path and error after a sysfs access failure.
Gracefully exit rather than crash.
Change-Id: I41316e84a70ceda8c166f31ab3269f97978da3ab
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'mainloop.cpp')
| -rw-r--r-- | mainloop.cpp | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/mainloop.cpp b/mainloop.cpp index 31b02ac..0077d33 100644 --- a/mainloop.cpp +++ b/mainloop.cpp @@ -110,7 +110,9 @@ auto getAttributes(const std::string& type, Attributes& attributes) } auto addValue(const SensorSet::key_type& sensor, - const std::string& sysfsRoot, ObjectInfo& info) + const std::string& hwmonRoot, + const std::string& instance, + ObjectInfo& info) { static constexpr bool deferSignals = true; @@ -119,14 +121,11 @@ auto addValue(const SensorSet::key_type& sensor, auto& obj = std::get<Object>(info); auto& objPath = std::get<std::string>(info); - auto sysfsPath = make_sysfs_path( - sysfsRoot, - sensor.first, - sensor.second, - hwmon::entry::input); - int val = 0; - read_sysfs(sysfsPath, val); - + int val = readSysfsWithCallout(hwmonRoot, + instance, + sensor.first, + sensor.second, + hwmon::entry::input); auto iface = std::make_shared<ValueObject>(bus, objPath.c_str(), deferSignals); iface->value(val); @@ -180,8 +179,7 @@ void MainLoop::shutdown() noexcept void MainLoop::run() { // Check sysfs for available sensors. - std::string hwmonPath = _hwmonRoot + '/' + _instance; - auto sensors = std::make_unique<SensorSet>(hwmonPath); + auto sensors = std::make_unique<SensorSet>(_hwmonRoot + '/' + _instance); for (auto& i : *sensors) { @@ -207,7 +205,7 @@ void MainLoop::run() objectPath.append(label); ObjectInfo info(&_bus, std::move(objectPath), Object()); - auto valueInterface = addValue(i.first, hwmonPath, info); + auto valueInterface = addValue(i.first, _hwmonRoot, _instance, info); auto sensorValue = valueInterface->value(); addThreshold<WarningObject>(i.first, sensorValue, info); addThreshold<CriticalObject>(i.first, sensorValue, info); @@ -244,12 +242,11 @@ void MainLoop::run() if (attrs.find(hwmon::entry::input) != attrs.end()) { // Read value from sensor. - int value = 0; - read_sysfs(make_sysfs_path(hwmonPath, - i.first.first, i.first.second, - hwmon::entry::input), - value); - + int value = readSysfsWithCallout(_hwmonRoot, + _instance, + i.first.first, + i.first.second, + hwmon::entry::input); auto& objInfo = std::get<ObjectInfo>(i.second); auto& obj = std::get<Object>(objInfo); |

