Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2016 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Matt Spinler | f9c83c4 | 2017-08-10 08:51:45 -0500 | [diff] [blame] | 16 | #include "config.h" |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 17 | |
| 18 | #include "mainloop.hpp" |
| 19 | |
Patrick Venture | 0979185 | 2018-04-17 17:40:00 -0700 | [diff] [blame] | 20 | #include "env.hpp" |
| 21 | #include "fan_pwm.hpp" |
| 22 | #include "fan_speed.hpp" |
Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 23 | #include "hwmon.hpp" |
Patrick Venture | 75e56c6 | 2018-04-20 18:10:15 -0700 | [diff] [blame] | 24 | #include "hwmonio.hpp" |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 25 | #include "sensor.hpp" |
Patrick Venture | 0979185 | 2018-04-17 17:40:00 -0700 | [diff] [blame] | 26 | #include "sensorset.hpp" |
Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 27 | #include "sysfs.hpp" |
Matthew Barth | bf7b7b1 | 2017-03-07 15:46:59 -0600 | [diff] [blame] | 28 | #include "targets.hpp" |
Patrick Venture | 0979185 | 2018-04-17 17:40:00 -0700 | [diff] [blame] | 29 | #include "thresholds.hpp" |
Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 30 | |
William A. Kennington III | 0e74975 | 2018-11-06 15:25:41 -0800 | [diff] [blame] | 31 | #include <cassert> |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 32 | #include <cstdlib> |
| 33 | #include <functional> |
| 34 | #include <iostream> |
| 35 | #include <memory> |
| 36 | #include <phosphor-logging/elog-errors.hpp> |
| 37 | #include <sstream> |
| 38 | #include <string> |
| 39 | #include <unordered_set> |
Patrick Venture | 1e6324f | 2017-06-01 14:07:05 -0700 | [diff] [blame] | 40 | #include <xyz/openbmc_project/Sensor/Device/error.hpp> |
| 41 | |
| 42 | using namespace phosphor::logging; |
| 43 | |
Saqib Khan | 973886d | 2017-03-15 14:01:16 -0500 | [diff] [blame] | 44 | // Initialization for Warning Objects |
| 45 | decltype(Thresholds<WarningObject>::setLo) Thresholds<WarningObject>::setLo = |
| 46 | &WarningObject::warningLow; |
| 47 | decltype(Thresholds<WarningObject>::setHi) Thresholds<WarningObject>::setHi = |
| 48 | &WarningObject::warningHigh; |
| 49 | decltype(Thresholds<WarningObject>::getLo) Thresholds<WarningObject>::getLo = |
| 50 | &WarningObject::warningLow; |
| 51 | decltype(Thresholds<WarningObject>::getHi) Thresholds<WarningObject>::getHi = |
| 52 | &WarningObject::warningHigh; |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 53 | decltype( |
| 54 | Thresholds<WarningObject>::alarmLo) Thresholds<WarningObject>::alarmLo = |
Saqib Khan | 973886d | 2017-03-15 14:01:16 -0500 | [diff] [blame] | 55 | &WarningObject::warningAlarmLow; |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 56 | decltype( |
| 57 | Thresholds<WarningObject>::alarmHi) Thresholds<WarningObject>::alarmHi = |
Saqib Khan | 973886d | 2017-03-15 14:01:16 -0500 | [diff] [blame] | 58 | &WarningObject::warningAlarmHigh; |
| 59 | |
| 60 | // Initialization for Critical Objects |
| 61 | decltype(Thresholds<CriticalObject>::setLo) Thresholds<CriticalObject>::setLo = |
| 62 | &CriticalObject::criticalLow; |
| 63 | decltype(Thresholds<CriticalObject>::setHi) Thresholds<CriticalObject>::setHi = |
| 64 | &CriticalObject::criticalHigh; |
| 65 | decltype(Thresholds<CriticalObject>::getLo) Thresholds<CriticalObject>::getLo = |
| 66 | &CriticalObject::criticalLow; |
| 67 | decltype(Thresholds<CriticalObject>::getHi) Thresholds<CriticalObject>::getHi = |
| 68 | &CriticalObject::criticalHigh; |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 69 | decltype( |
| 70 | Thresholds<CriticalObject>::alarmLo) Thresholds<CriticalObject>::alarmLo = |
Saqib Khan | 973886d | 2017-03-15 14:01:16 -0500 | [diff] [blame] | 71 | &CriticalObject::criticalAlarmLow; |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 72 | decltype( |
| 73 | Thresholds<CriticalObject>::alarmHi) Thresholds<CriticalObject>::alarmHi = |
Saqib Khan | 973886d | 2017-03-15 14:01:16 -0500 | [diff] [blame] | 74 | &CriticalObject::criticalAlarmHigh; |
| 75 | |
Patrick Venture | feb744a | 2019-06-26 19:07:48 -0700 | [diff] [blame] | 76 | void updateSensorInterfaces(InterfaceMap& ifaces, int64_t value) |
| 77 | { |
| 78 | for (auto& iface : ifaces) |
| 79 | { |
| 80 | switch (iface.first) |
| 81 | { |
| 82 | case InterfaceType::VALUE: |
| 83 | { |
| 84 | auto& valueIface = |
| 85 | std::any_cast<std::shared_ptr<ValueObject>&>(iface.second); |
| 86 | valueIface->value(value); |
| 87 | } |
| 88 | break; |
| 89 | case InterfaceType::WARN: |
| 90 | checkThresholds<WarningObject>(iface.second, value); |
| 91 | break; |
| 92 | case InterfaceType::CRIT: |
| 93 | checkThresholds<CriticalObject>(iface.second, value); |
| 94 | break; |
| 95 | default: |
| 96 | break; |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 101 | std::string MainLoop::getID(SensorSet::container_t::const_reference sensor) |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 102 | { |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 103 | std::string id; |
| 104 | |
| 105 | /* |
| 106 | * Check if the value of the MODE_<item><X> env variable for the sensor |
Matt Spinler | 7c42480 | 2018-05-04 10:52:40 -0500 | [diff] [blame] | 107 | * is set. If it is, then read the from the <item><X>_<mode> |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 108 | * file. The name of the DBUS object would be the value of the env |
Matt Spinler | 7c42480 | 2018-05-04 10:52:40 -0500 | [diff] [blame] | 109 | * variable LABEL_<item><mode value>. If the MODE_<item><X> env variable |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 110 | * doesn't exist, then the name of DBUS object is the value of the env |
| 111 | * variable LABEL_<item><X>. |
Matt Spinler | 7c42480 | 2018-05-04 10:52:40 -0500 | [diff] [blame] | 112 | * |
| 113 | * For example, if MODE_temp1 = "label", then code reads the temp1_label |
| 114 | * file. If it has a 5 in it, then it will use the following entry to |
| 115 | * name the object: LABEL_temp5 = "My DBus object name". |
| 116 | * |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 117 | */ |
Patrick Venture | 7a5285d | 2018-04-17 19:15:05 -0700 | [diff] [blame] | 118 | auto mode = env::getEnv("MODE", sensor.first); |
Matt Spinler | 7c42480 | 2018-05-04 10:52:40 -0500 | [diff] [blame] | 119 | if (!mode.empty()) |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 120 | { |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 121 | id = env::getIndirectID(_hwmonRoot + '/' + _instance + '/', mode, |
| 122 | sensor.first); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 123 | |
| 124 | if (id.empty()) |
| 125 | { |
Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 126 | return id; |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 127 | } |
| 128 | } |
| 129 | |
| 130 | // Use the ID we looked up above if there was one, |
| 131 | // otherwise use the standard one. |
| 132 | id = (id.empty()) ? sensor.first.second : id; |
| 133 | |
Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 134 | return id; |
| 135 | } |
| 136 | |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 137 | SensorIdentifiers |
| 138 | MainLoop::getIdentifiers(SensorSet::container_t::const_reference sensor) |
Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 139 | { |
| 140 | std::string id = getID(sensor); |
| 141 | std::string label; |
| 142 | |
| 143 | if (!id.empty()) |
| 144 | { |
| 145 | // Ignore inputs without a label. |
| 146 | label = env::getEnv("LABEL", sensor.first.first, id); |
| 147 | } |
| 148 | |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 149 | return std::make_tuple(std::move(id), std::move(label)); |
Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Reads the environment parameters of a sensor and creates an object with |
| 154 | * atleast the `Value` interface, otherwise returns without creating the object. |
| 155 | * If the `Value` interface is successfully created, by reading the sensor's |
| 156 | * corresponding sysfs file's value, the additional interfaces for the sensor |
Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 157 | * are created and the InterfacesAdded signal is emitted. The object's state |
| 158 | * data is then returned for sensor state monitoring within the main loop. |
Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 159 | */ |
William A. Kennington III | 4cbdfef | 2018-10-18 19:19:51 -0700 | [diff] [blame] | 160 | std::optional<ObjectStateData> |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 161 | MainLoop::getObject(SensorSet::container_t::const_reference sensor) |
Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 162 | { |
| 163 | auto properties = getIdentifiers(sensor); |
| 164 | if (std::get<sensorID>(properties).empty() || |
| 165 | std::get<sensorLabel>(properties).empty()) |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 166 | { |
Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 167 | return {}; |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 168 | } |
| 169 | |
Patrick Venture | 0979185 | 2018-04-17 17:40:00 -0700 | [diff] [blame] | 170 | hwmon::Attributes attrs; |
| 171 | if (!hwmon::getAttributes(sensor.first.first, attrs)) |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 172 | { |
Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 173 | return {}; |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 174 | } |
| 175 | |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 176 | const auto& [sensorSetKey, sensorAttrs] = sensor; |
| 177 | const auto& [sensorSysfsType, sensorSysfsNum] = sensorSetKey; |
| 178 | |
Patrick Venture | 2864b06 | 2018-12-19 08:13:41 -0800 | [diff] [blame] | 179 | /* Note: The sensor objects all share the same ioAccess object. */ |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 180 | auto sensorObj = |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 181 | std::make_unique<sensor::Sensor>(sensorSetKey, _ioAccess, _devPath); |
Matthew Barth | 9c43106 | 2018-05-07 13:55:29 -0500 | [diff] [blame] | 182 | |
Matthew Barth | b798527 | 2018-04-17 10:50:36 -0500 | [diff] [blame] | 183 | // Get list of return codes for removing sensors on device |
| 184 | auto devRmRCs = env::getEnv("REMOVERCS"); |
| 185 | // Add sensor removal return codes defined at the device level |
Matthew Barth | cb3daaf | 2018-05-07 15:03:16 -0500 | [diff] [blame] | 186 | sensorObj->addRemoveRCs(devRmRCs); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 187 | |
| 188 | std::string objectPath{_root}; |
| 189 | objectPath.append(1, '/'); |
Patrick Venture | 0979185 | 2018-04-17 17:40:00 -0700 | [diff] [blame] | 190 | objectPath.append(hwmon::getNamespace(attrs)); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 191 | objectPath.append(1, '/'); |
Matthew Barth | 979c806 | 2018-04-17 11:37:15 -0500 | [diff] [blame] | 192 | objectPath.append(std::get<sensorLabel>(properties)); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 193 | |
Patrick Venture | 6206723 | 2019-06-19 17:39:33 -0700 | [diff] [blame] | 194 | ObjectInfo info(&_bus, std::move(objectPath), InterfaceMap()); |
Patrick Venture | 75e56c6 | 2018-04-20 18:10:15 -0700 | [diff] [blame] | 195 | RetryIO retryIO(hwmonio::retries, hwmonio::delay); |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 196 | if (_rmSensors.find(sensorSetKey) != _rmSensors.end()) |
Matthew Barth | d4beecf | 2018-04-03 15:50:22 -0500 | [diff] [blame] | 197 | { |
| 198 | // When adding a sensor that was purposely removed, |
| 199 | // don't retry on errors when reading its value |
| 200 | std::get<size_t>(retryIO) = 0; |
| 201 | } |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 202 | auto valueInterface = static_cast<std::shared_ptr<ValueObject>>(nullptr); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 203 | try |
| 204 | { |
Matthew Barth | ca44c2e | 2018-04-24 15:33:25 -0500 | [diff] [blame] | 205 | // Add status interface based on _fault file being present |
Matthew Barth | 2e41b13 | 2018-05-07 14:15:45 -0500 | [diff] [blame] | 206 | sensorObj->addStatus(info); |
Matthew Barth | cb3daaf | 2018-05-07 15:03:16 -0500 | [diff] [blame] | 207 | valueInterface = sensorObj->addValue(retryIO, info); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 208 | } |
| 209 | catch (const std::system_error& e) |
| 210 | { |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 211 | auto file = |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 212 | sysfs::make_sysfs_path(_ioAccess->path(), sensorSysfsType, |
| 213 | sensorSysfsNum, hwmon::entry::cinput); |
Patrick Venture | 0892c3f | 2019-06-27 14:24:03 -0700 | [diff] [blame] | 214 | |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 215 | // Check sensorAdjusts for sensor removal RCs |
Matthew Barth | ac47309 | 2018-05-07 14:41:46 -0500 | [diff] [blame] | 216 | auto& sAdjusts = sensorObj->getAdjusts(); |
| 217 | if (sAdjusts.rmRCs.count(e.code().value()) > 0) |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 218 | { |
Matthew Barth | ac47309 | 2018-05-07 14:41:46 -0500 | [diff] [blame] | 219 | // Return code found in sensor return code removal list |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 220 | if (_rmSensors.find(sensorSetKey) == _rmSensors.end()) |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 221 | { |
Matthew Barth | ac47309 | 2018-05-07 14:41:46 -0500 | [diff] [blame] | 222 | // Trace for sensor not already removed from dbus |
| 223 | log<level::INFO>("Sensor not added to dbus for read fail", |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 224 | entry("FILE=%s", file.c_str()), |
| 225 | entry("RC=%d", e.code().value())); |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 226 | _rmSensors[std::move(sensorSetKey)] = std::move(sensorAttrs); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 227 | } |
Matthew Barth | ac47309 | 2018-05-07 14:41:46 -0500 | [diff] [blame] | 228 | return {}; |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 229 | } |
Patrick Venture | 0892c3f | 2019-06-27 14:24:03 -0700 | [diff] [blame] | 230 | |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 231 | using namespace sdbusplus::xyz::openbmc_project::Sensor::Device::Error; |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 232 | report<ReadFailure>( |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 233 | xyz::openbmc_project::Sensor::Device::ReadFailure::CALLOUT_ERRNO( |
| 234 | e.code().value()), |
| 235 | xyz::openbmc_project::Sensor::Device::ReadFailure:: |
| 236 | CALLOUT_DEVICE_PATH(_devPath.c_str())); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 237 | |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 238 | log<level::INFO>("Logging failing sysfs file", |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 239 | entry("FILE=%s", file.c_str())); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 240 | exit(EXIT_FAILURE); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 241 | } |
| 242 | auto sensorValue = valueInterface->value(); |
James Feist | ee73f5b | 2018-08-01 16:31:42 -0700 | [diff] [blame] | 243 | int64_t scale = 0; |
| 244 | // scale the thresholds only if we're using doubles |
| 245 | if constexpr (std::is_same<SensorValueType, double>::value) |
| 246 | { |
| 247 | scale = sensorObj->getScale(); |
| 248 | } |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 249 | addThreshold<WarningObject>(sensorSysfsType, std::get<sensorID>(properties), |
| 250 | sensorValue, info, scale); |
| 251 | addThreshold<CriticalObject>(sensorSysfsType, |
James Feist | ee73f5b | 2018-08-01 16:31:42 -0700 | [diff] [blame] | 252 | std::get<sensorID>(properties), sensorValue, |
| 253 | info, scale); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 254 | |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 255 | auto target = |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 256 | addTarget<hwmon::FanSpeed>(sensorSetKey, _ioAccess, _devPath, info); |
Matthew Barth | 28f8e66 | 2018-03-26 16:57:36 -0500 | [diff] [blame] | 257 | if (target) |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 258 | { |
Matthew Barth | 28f8e66 | 2018-03-26 16:57:36 -0500 | [diff] [blame] | 259 | target->enable(); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 260 | } |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 261 | addTarget<hwmon::FanPwm>(sensorSetKey, _ioAccess, _devPath, info); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 262 | |
| 263 | // All the interfaces have been created. Go ahead |
| 264 | // and emit InterfacesAdded. |
| 265 | valueInterface->emit_object_added(); |
| 266 | |
Matthew Barth | 9c43106 | 2018-05-07 13:55:29 -0500 | [diff] [blame] | 267 | // Save sensor object specifications |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 268 | _sensorObjects[sensorSetKey] = std::move(sensorObj); |
Matthew Barth | 9c43106 | 2018-05-07 13:55:29 -0500 | [diff] [blame] | 269 | |
Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 270 | return std::make_pair(std::move(std::get<sensorLabel>(properties)), |
| 271 | std::move(info)); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 272 | } |
| 273 | |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 274 | MainLoop::MainLoop(sdbusplus::bus::bus&& bus, const std::string& param, |
| 275 | const std::string& path, const std::string& devPath, |
Patrick Venture | 16805a6 | 2019-06-21 14:19:33 -0700 | [diff] [blame] | 276 | const char* prefix, const char* root, |
| 277 | const hwmonio::HwmonIOInterface* ioIntf) : |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 278 | _bus(std::move(bus)), |
| 279 | _manager(_bus, root), _pathParam(param), _hwmonRoot(), _instance(), |
Patrick Venture | 16805a6 | 2019-06-21 14:19:33 -0700 | [diff] [blame] | 280 | _devPath(devPath), _prefix(prefix), _root(root), _state(), |
| 281 | _ioAccess(ioIntf), _event(sdeventplus::Event::get_default()), |
Patrick Venture | 52b4061 | 2018-12-19 13:36:41 -0800 | [diff] [blame] | 282 | _timer(_event, std::bind(&MainLoop::read, this)) |
Brad Bishop | d499ca6 | 2016-12-19 09:24:50 -0500 | [diff] [blame] | 283 | { |
Patrick Venture | 73a50c7 | 2018-04-17 15:19:03 -0700 | [diff] [blame] | 284 | // Strip off any trailing slashes. |
Brad Bishop | b8740fc | 2017-02-24 23:38:37 -0500 | [diff] [blame] | 285 | std::string p = path; |
| 286 | while (!p.empty() && p.back() == '/') |
Brad Bishop | 9c7b6e0 | 2016-12-19 12:43:36 -0500 | [diff] [blame] | 287 | { |
Brad Bishop | b8740fc | 2017-02-24 23:38:37 -0500 | [diff] [blame] | 288 | p.pop_back(); |
Brad Bishop | 9c7b6e0 | 2016-12-19 12:43:36 -0500 | [diff] [blame] | 289 | } |
Brad Bishop | b8740fc | 2017-02-24 23:38:37 -0500 | [diff] [blame] | 290 | |
Patrick Venture | 73a50c7 | 2018-04-17 15:19:03 -0700 | [diff] [blame] | 291 | // Given the furthest right /, set instance to |
| 292 | // the basename, and hwmonRoot to the leading path. |
Brad Bishop | b8740fc | 2017-02-24 23:38:37 -0500 | [diff] [blame] | 293 | auto n = p.rfind('/'); |
| 294 | if (n != std::string::npos) |
| 295 | { |
| 296 | _instance.assign(p.substr(n + 1)); |
| 297 | _hwmonRoot.assign(p.substr(0, n)); |
| 298 | } |
| 299 | |
| 300 | assert(!_instance.empty()); |
| 301 | assert(!_hwmonRoot.empty()); |
Brad Bishop | d499ca6 | 2016-12-19 09:24:50 -0500 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | void MainLoop::shutdown() noexcept |
| 305 | { |
Patrick Venture | 52b4061 | 2018-12-19 13:36:41 -0800 | [diff] [blame] | 306 | _event.exit(0); |
Brad Bishop | d499ca6 | 2016-12-19 09:24:50 -0500 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | void MainLoop::run() |
Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 310 | { |
Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 311 | init(); |
| 312 | |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 313 | std::function<void()> callback(std::bind(&MainLoop::read, this)); |
Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 314 | try |
| 315 | { |
Patrick Venture | 52b4061 | 2018-12-19 13:36:41 -0800 | [diff] [blame] | 316 | _timer.restart(std::chrono::microseconds(_interval)); |
Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 317 | |
| 318 | // TODO: Issue#6 - Optionally look at polling interval sysfs entry. |
| 319 | |
| 320 | // TODO: Issue#7 - Should probably periodically check the SensorSet |
| 321 | // for new entries. |
| 322 | |
Patrick Venture | 52b4061 | 2018-12-19 13:36:41 -0800 | [diff] [blame] | 323 | _bus.attach_event(_event.get(), SD_EVENT_PRIORITY_IMPORTANT); |
| 324 | _event.loop(); |
Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 325 | } |
William A. Kennington III | 0fe4cb3 | 2018-10-18 19:19:58 -0700 | [diff] [blame] | 326 | catch (const std::exception& e) |
Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 327 | { |
| 328 | log<level::ERR>("Error in sysfs polling loop", |
| 329 | entry("ERROR=%s", e.what())); |
| 330 | throw; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | void MainLoop::init() |
| 335 | { |
Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 336 | // Check sysfs for available sensors. |
Brad Bishop | 4db6442 | 2017-02-16 11:33:32 -0500 | [diff] [blame] | 337 | auto sensors = std::make_unique<SensorSet>(_hwmonRoot + '/' + _instance); |
Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 338 | |
Patrick Venture | db7ecb6 | 2018-10-23 19:42:23 -0700 | [diff] [blame] | 339 | for (const auto& i : *sensors) |
Brad Bishop | 75b4ab8 | 2017-01-06 09:33:50 -0500 | [diff] [blame] | 340 | { |
Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 341 | auto object = getObject(i); |
| 342 | if (object) |
| 343 | { |
| 344 | // Construct the SensorSet value |
| 345 | // std::tuple<SensorSet::mapped_type, |
| 346 | // std::string(Sensor Label), |
| 347 | // ObjectInfo> |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 348 | auto value = |
| 349 | std::make_tuple(std::move(i.second), std::move((*object).first), |
| 350 | std::move((*object).second)); |
Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 351 | |
Patrick Venture | 52b4061 | 2018-12-19 13:36:41 -0800 | [diff] [blame] | 352 | _state[std::move(i.first)] = std::move(value); |
Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 353 | } |
Brad Bishop | 75b4ab8 | 2017-01-06 09:33:50 -0500 | [diff] [blame] | 354 | } |
| 355 | |
Patrick Venture | 62503a4 | 2017-05-23 07:30:29 -0700 | [diff] [blame] | 356 | /* If there are no sensors specified by labels, exit. */ |
Patrick Venture | 52b4061 | 2018-12-19 13:36:41 -0800 | [diff] [blame] | 357 | if (0 == _state.size()) |
Patrick Venture | 62503a4 | 2017-05-23 07:30:29 -0700 | [diff] [blame] | 358 | { |
Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 359 | exit(0); |
Patrick Venture | 62503a4 | 2017-05-23 07:30:29 -0700 | [diff] [blame] | 360 | } |
| 361 | |
Brad Bishop | 9c7b6e0 | 2016-12-19 12:43:36 -0500 | [diff] [blame] | 362 | { |
Patrick Venture | c897d8b | 2018-04-23 19:01:56 -0700 | [diff] [blame] | 363 | std::stringstream ss; |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 364 | ss << _prefix << "-" |
Patrick Venture | c897d8b | 2018-04-23 19:01:56 -0700 | [diff] [blame] | 365 | << std::to_string(std::hash<std::string>{}(_devPath + _pathParam)) |
| 366 | << ".Hwmon1"; |
| 367 | |
| 368 | _bus.request_name(ss.str().c_str()); |
Brad Bishop | 9c7b6e0 | 2016-12-19 12:43:36 -0500 | [diff] [blame] | 369 | } |
| 370 | |
Patrick Venture | ab10f16 | 2017-05-22 09:44:50 -0700 | [diff] [blame] | 371 | { |
Patrick Venture | a24c880 | 2018-04-17 19:38:06 -0700 | [diff] [blame] | 372 | auto interval = env::getEnv("INTERVAL"); |
| 373 | if (!interval.empty()) |
Patrick Venture | ab10f16 | 2017-05-22 09:44:50 -0700 | [diff] [blame] | 374 | { |
Patrick Venture | 50cf1c5 | 2018-04-18 09:21:41 -0700 | [diff] [blame] | 375 | _interval = std::strtoull(interval.c_str(), NULL, 10); |
Patrick Venture | ab10f16 | 2017-05-22 09:44:50 -0700 | [diff] [blame] | 376 | } |
| 377 | } |
Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 378 | } |
Patrick Venture | ab10f16 | 2017-05-22 09:44:50 -0700 | [diff] [blame] | 379 | |
Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 380 | void MainLoop::read() |
| 381 | { |
Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 382 | // TODO: Issue#3 - Need to make calls to the dbus sensor cache here to |
| 383 | // ensure the objects all exist? |
| 384 | |
Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 385 | // Iterate through all the sensors. |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 386 | for (auto& [sensorSetKey, sensorStateTuple] : _state) |
Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 387 | { |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 388 | const auto& [sensorSysfsType, sensorSysfsNum] = sensorSetKey; |
| 389 | auto& [attrs, unused, objInfo] = sensorStateTuple; |
| 390 | |
Kun Yi | 553552c | 2019-07-15 22:14:21 -0700 | [diff] [blame] | 391 | if (attrs.find(hwmon::entry::input) == attrs.end()) |
Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 392 | { |
Kun Yi | 553552c | 2019-07-15 22:14:21 -0700 | [diff] [blame] | 393 | continue; |
| 394 | } |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 395 | |
Kun Yi | 553552c | 2019-07-15 22:14:21 -0700 | [diff] [blame] | 396 | // Read value from sensor. |
| 397 | std::string input = hwmon::entry::cinput; |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 398 | if (sensorSysfsType == "pwm") |
Kun Yi | 553552c | 2019-07-15 22:14:21 -0700 | [diff] [blame] | 399 | { |
| 400 | input = ""; |
| 401 | } |
| 402 | |
| 403 | int64_t value; |
Kun Yi | 553552c | 2019-07-15 22:14:21 -0700 | [diff] [blame] | 404 | auto& obj = std::get<InterfaceMap>(objInfo); |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 405 | std::unique_ptr<sensor::Sensor>& sensor = _sensorObjects[sensorSetKey]; |
Kun Yi | 553552c | 2019-07-15 22:14:21 -0700 | [diff] [blame] | 406 | |
| 407 | auto& statusIface = std::any_cast<std::shared_ptr<StatusObject>&>( |
| 408 | obj[InterfaceType::STATUS]); |
| 409 | // As long as addStatus is called before addValue, statusIface |
| 410 | // should never be nullptr. |
| 411 | assert(statusIface); |
| 412 | |
| 413 | try |
| 414 | { |
| 415 | if (sensor->hasFaultFile()) |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 416 | { |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 417 | auto fault = _ioAccess->read(sensorSysfsType, sensorSysfsNum, |
Kun Yi | 553552c | 2019-07-15 22:14:21 -0700 | [diff] [blame] | 418 | hwmon::entry::fault, |
| 419 | hwmonio::retries, hwmonio::delay); |
| 420 | // Skip reading from a sensor with a valid fault file |
| 421 | // and set the functional property accordingly |
| 422 | if (!statusIface->functional((fault == 0) ? true : false)) |
Matthew Barth | 27c4a39 | 2018-04-25 14:38:51 -0500 | [diff] [blame] | 423 | { |
Matthew Barth | ac47309 | 2018-05-07 14:41:46 -0500 | [diff] [blame] | 424 | continue; |
Matthew Barth | 8772ce3 | 2018-03-22 16:03:06 -0500 | [diff] [blame] | 425 | } |
Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 426 | } |
Kun Yi | 553552c | 2019-07-15 22:14:21 -0700 | [diff] [blame] | 427 | |
| 428 | { |
| 429 | // RAII object for GPIO unlock / lock |
| 430 | sensor::GpioLock gpioLock(sensor->getGpio()); |
| 431 | |
| 432 | // Retry for up to a second if device is busy |
| 433 | // or has a transient error. |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 434 | value = _ioAccess->read(sensorSysfsType, sensorSysfsNum, input, |
Kun Yi | 553552c | 2019-07-15 22:14:21 -0700 | [diff] [blame] | 435 | hwmonio::retries, hwmonio::delay); |
| 436 | // Set functional property to true if we could read sensor |
| 437 | statusIface->functional(true); |
| 438 | |
| 439 | value = sensor->adjustValue(value); |
| 440 | } |
| 441 | |
| 442 | updateSensorInterfaces(obj, value); |
| 443 | } |
| 444 | catch (const std::system_error& e) |
| 445 | { |
| 446 | #ifdef UPDATE_FUNCTIONAL_ON_FAIL |
| 447 | // If UPDATE_FUNCTIONAL_ON_FAIL is defined and an exception was |
| 448 | // thrown, set the functional property to false. |
| 449 | // We cannot set this with the 'continue' in the lower block |
| 450 | // as the code may exit before reaching it. |
| 451 | statusIface->functional(false); |
| 452 | #endif |
| 453 | auto file = |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 454 | sysfs::make_sysfs_path(_ioAccess->path(), sensorSysfsType, |
| 455 | sensorSysfsNum, hwmon::entry::cinput); |
Kun Yi | 553552c | 2019-07-15 22:14:21 -0700 | [diff] [blame] | 456 | |
| 457 | // Check sensorAdjusts for sensor removal RCs |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 458 | auto& sAdjusts = _sensorObjects[sensorSetKey]->getAdjusts(); |
Kun Yi | 553552c | 2019-07-15 22:14:21 -0700 | [diff] [blame] | 459 | if (sAdjusts.rmRCs.count(e.code().value()) > 0) |
| 460 | { |
| 461 | // Return code found in sensor return code removal list |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 462 | if (_rmSensors.find(sensorSetKey) == _rmSensors.end()) |
Kun Yi | 553552c | 2019-07-15 22:14:21 -0700 | [diff] [blame] | 463 | { |
| 464 | // Trace for sensor not already removed from dbus |
| 465 | log<level::INFO>("Remove sensor from dbus for read fail", |
| 466 | entry("FILE=%s", file.c_str()), |
| 467 | entry("RC=%d", e.code().value())); |
| 468 | // Mark this sensor to be removed from dbus |
Kun Yi | 501ade2 | 2019-07-15 15:00:32 -0700 | [diff] [blame^] | 469 | _rmSensors[sensorSetKey] = attrs; |
Kun Yi | 553552c | 2019-07-15 22:14:21 -0700 | [diff] [blame] | 470 | } |
| 471 | continue; |
| 472 | } |
| 473 | #ifdef UPDATE_FUNCTIONAL_ON_FAIL |
| 474 | // Do not exit with failure if UPDATE_FUNCTIONAL_ON_FAIL is set |
| 475 | continue; |
| 476 | #endif |
| 477 | using namespace sdbusplus::xyz::openbmc_project::Sensor::Device:: |
| 478 | Error; |
| 479 | report<ReadFailure>( |
| 480 | xyz::openbmc_project::Sensor::Device::ReadFailure:: |
| 481 | CALLOUT_ERRNO(e.code().value()), |
| 482 | xyz::openbmc_project::Sensor::Device::ReadFailure:: |
| 483 | CALLOUT_DEVICE_PATH(_devPath.c_str())); |
| 484 | |
| 485 | log<level::INFO>("Logging failing sysfs file", |
| 486 | entry("FILE=%s", file.c_str())); |
| 487 | |
| 488 | exit(EXIT_FAILURE); |
Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 489 | } |
Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 490 | } |
Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 491 | |
Patrick Venture | 0cd4f69 | 2019-06-21 13:39:40 -0700 | [diff] [blame] | 492 | removeSensors(); |
| 493 | |
Patrick Venture | 0cd4f69 | 2019-06-21 13:39:40 -0700 | [diff] [blame] | 494 | addDroppedSensors(); |
Patrick Venture | 0cd4f69 | 2019-06-21 13:39:40 -0700 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | void MainLoop::removeSensors() |
| 498 | { |
Matthew Barth | 8772ce3 | 2018-03-22 16:03:06 -0500 | [diff] [blame] | 499 | // Remove any sensors marked for removal |
Patrick Venture | 52b4061 | 2018-12-19 13:36:41 -0800 | [diff] [blame] | 500 | for (const auto& i : _rmSensors) |
Deepak Kodihalli | 2a51a9c | 2018-03-07 02:39:40 -0600 | [diff] [blame] | 501 | { |
Matthew Barth | d0ce792 | 2019-06-06 09:23:37 -0500 | [diff] [blame] | 502 | // Remove sensor object from dbus using emit_object_removed() |
| 503 | auto& objInfo = std::get<ObjectInfo>(_state[i.first]); |
| 504 | auto& objPath = std::get<std::string>(objInfo); |
Patrick Venture | 0cd4f69 | 2019-06-21 13:39:40 -0700 | [diff] [blame] | 505 | |
Matthew Barth | d0ce792 | 2019-06-06 09:23:37 -0500 | [diff] [blame] | 506 | _bus.emit_object_removed(objPath.c_str()); |
Patrick Venture | 0cd4f69 | 2019-06-21 13:39:40 -0700 | [diff] [blame] | 507 | |
Matthew Barth | d0ce792 | 2019-06-06 09:23:37 -0500 | [diff] [blame] | 508 | // Erase sensor object info |
Patrick Venture | 52b4061 | 2018-12-19 13:36:41 -0800 | [diff] [blame] | 509 | _state.erase(i.first); |
Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 510 | } |
Patrick Venture | 0cd4f69 | 2019-06-21 13:39:40 -0700 | [diff] [blame] | 511 | } |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 512 | |
Patrick Venture | 0cd4f69 | 2019-06-21 13:39:40 -0700 | [diff] [blame] | 513 | void MainLoop::addDroppedSensors() |
| 514 | { |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 515 | // Attempt to add any sensors that were removed |
Patrick Venture | 52b4061 | 2018-12-19 13:36:41 -0800 | [diff] [blame] | 516 | auto it = _rmSensors.begin(); |
| 517 | while (it != _rmSensors.end()) |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 518 | { |
Patrick Venture | 52b4061 | 2018-12-19 13:36:41 -0800 | [diff] [blame] | 519 | if (_state.find(it->first) == _state.end()) |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 520 | { |
| 521 | SensorSet::container_t::value_type ssValueType = |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 522 | std::make_pair(it->first, it->second); |
Patrick Venture | 0cd4f69 | 2019-06-21 13:39:40 -0700 | [diff] [blame] | 523 | |
Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 524 | auto object = getObject(ssValueType); |
| 525 | if (object) |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 526 | { |
Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 527 | // Construct the SensorSet value |
| 528 | // std::tuple<SensorSet::mapped_type, |
| 529 | // std::string(Sensor Label), |
| 530 | // ObjectInfo> |
| 531 | auto value = std::make_tuple(std::move(ssValueType.second), |
| 532 | std::move((*object).first), |
| 533 | std::move((*object).second)); |
| 534 | |
Patrick Venture | 52b4061 | 2018-12-19 13:36:41 -0800 | [diff] [blame] | 535 | _state[std::move(ssValueType.first)] = std::move(value); |
Matthew Barth | d238e23 | 2018-04-17 12:01:50 -0500 | [diff] [blame] | 536 | |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 537 | // Sensor object added, erase entry from removal list |
Matthew Barth | 38c74e7 | 2018-04-02 12:41:26 -0500 | [diff] [blame] | 538 | auto file = sysfs::make_sysfs_path( |
Patrick Venture | 16805a6 | 2019-06-21 14:19:33 -0700 | [diff] [blame] | 539 | _ioAccess->path(), it->first.first, it->first.second, |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 540 | hwmon::entry::cinput); |
Patrick Venture | 0cd4f69 | 2019-06-21 13:39:40 -0700 | [diff] [blame] | 541 | |
Patrick Venture | 043d323 | 2018-08-31 10:10:53 -0700 | [diff] [blame] | 542 | log<level::INFO>("Added sensor to dbus after successful read", |
| 543 | entry("FILE=%s", file.c_str())); |
Patrick Venture | 0cd4f69 | 2019-06-21 13:39:40 -0700 | [diff] [blame] | 544 | |
Patrick Venture | 52b4061 | 2018-12-19 13:36:41 -0800 | [diff] [blame] | 545 | it = _rmSensors.erase(it); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 546 | } |
| 547 | else |
| 548 | { |
| 549 | ++it; |
| 550 | } |
| 551 | } |
| 552 | else |
| 553 | { |
| 554 | // Sanity check to remove sensors that were re-added |
Patrick Venture | 52b4061 | 2018-12-19 13:36:41 -0800 | [diff] [blame] | 555 | it = _rmSensors.erase(it); |
Matthew Barth | 31d214c | 2018-03-26 09:54:27 -0500 | [diff] [blame] | 556 | } |
| 557 | } |
Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 |