James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2017 Intel 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 | */ |
| 16 | |
Andrew Jeffery | e73bd0a | 2023-01-25 10:39:57 +1030 | [diff] [blame] | 17 | #include "DeviceMgmt.hpp" |
| 18 | #include "HwmonTempSensor.hpp" |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 19 | #include "SensorPaths.hpp" |
| 20 | #include "Thresholds.hpp" |
Andrew Jeffery | e73bd0a | 2023-01-25 10:39:57 +1030 | [diff] [blame] | 21 | #include "Utils.hpp" |
| 22 | |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 23 | #include <boost/asio/error.hpp> |
| 24 | #include <boost/asio/io_context.hpp> |
| 25 | #include <boost/asio/post.hpp> |
| 26 | #include <boost/asio/steady_timer.hpp> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 27 | #include <boost/container/flat_map.hpp> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 28 | #include <boost/container/flat_set.hpp> |
George Liu | 8b06518 | 2025-02-20 14:08:47 +0800 | [diff] [blame] | 29 | #include <phosphor-logging/lg2.hpp> |
| 30 | #include <phosphor-logging/lg2/flags.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 31 | #include <sdbusplus/asio/connection.hpp> |
| 32 | #include <sdbusplus/asio/object_server.hpp> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 33 | #include <sdbusplus/bus.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 34 | #include <sdbusplus/bus/match.hpp> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 35 | #include <sdbusplus/message.hpp> |
| 36 | #include <sdbusplus/message/native_types.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 37 | |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 38 | #include <algorithm> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 39 | #include <array> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 40 | #include <chrono> |
| 41 | #include <cstddef> |
| 42 | #include <cstdint> |
James Feist | 24f02f2 | 2019-04-15 11:05:39 -0700 | [diff] [blame] | 43 | #include <filesystem> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 44 | #include <functional> |
| 45 | #include <memory> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 46 | #include <optional> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 47 | #include <regex> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 48 | #include <string> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 49 | #include <system_error> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 50 | #include <utility> |
| 51 | #include <variant> |
| 52 | #include <vector> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 53 | |
Jeff Lin | 87bc67f | 2020-12-04 20:58:01 +0800 | [diff] [blame] | 54 | static constexpr float pollRateDefault = 0.5; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 55 | |
Zhikui Ren | cb359da | 2023-08-03 16:45:44 -0700 | [diff] [blame] | 56 | static constexpr double maxValuePressure = 120000; // Pascals |
| 57 | static constexpr double minValuePressure = 30000; // Pascals |
Bruce Mitchell | 544e7dc | 2021-07-29 18:05:49 -0500 | [diff] [blame] | 58 | |
Bruce Mitchell | 3ec41c5 | 2021-12-10 16:05:17 -0600 | [diff] [blame] | 59 | static constexpr double maxValueRelativeHumidity = 100; // PercentRH |
| 60 | static constexpr double minValueRelativeHumidity = 0; // PercentRH |
| 61 | |
Zhikui Ren | cb359da | 2023-08-03 16:45:44 -0700 | [diff] [blame] | 62 | static constexpr double maxValueTemperature = 127; // DegreesC |
| 63 | static constexpr double minValueTemperature = -128; // DegreesC |
Bruce Mitchell | 544e7dc | 2021-07-29 18:05:49 -0500 | [diff] [blame] | 64 | |
Zev Weiss | d29f8aa | 2022-08-03 16:24:59 -0700 | [diff] [blame] | 65 | static const I2CDeviceTypeMap sensorTypes{ |
Patrick Rudolph | 76d3676 | 2023-09-20 16:53:38 +0200 | [diff] [blame] | 66 | {"ADM1021", I2CDeviceType{"adm1021", true}}, |
Zev Weiss | d29f8aa | 2022-08-03 16:24:59 -0700 | [diff] [blame] | 67 | {"DPS310", I2CDeviceType{"dps310", false}}, |
Delphine CC Chiu | 53896db | 2024-06-07 18:36:13 +0800 | [diff] [blame] | 68 | {"EMC1403", I2CDeviceType{"emc1403", true}}, |
Zev Weiss | d29f8aa | 2022-08-03 16:24:59 -0700 | [diff] [blame] | 69 | {"EMC1412", I2CDeviceType{"emc1412", true}}, |
| 70 | {"EMC1413", I2CDeviceType{"emc1413", true}}, |
| 71 | {"EMC1414", I2CDeviceType{"emc1414", true}}, |
| 72 | {"HDC1080", I2CDeviceType{"hdc1080", false}}, |
| 73 | {"JC42", I2CDeviceType{"jc42", true}}, |
| 74 | {"LM75A", I2CDeviceType{"lm75a", true}}, |
| 75 | {"LM95234", I2CDeviceType{"lm95234", true}}, |
| 76 | {"MAX31725", I2CDeviceType{"max31725", true}}, |
| 77 | {"MAX31730", I2CDeviceType{"max31730", true}}, |
| 78 | {"MAX6581", I2CDeviceType{"max6581", true}}, |
| 79 | {"MAX6654", I2CDeviceType{"max6654", true}}, |
Patrick Rudolph | f3862ee | 2023-10-23 14:13:06 +0200 | [diff] [blame] | 80 | {"MAX6639", I2CDeviceType{"max6639", true}}, |
Potin Lai | 28b8823 | 2023-12-13 16:41:01 +0800 | [diff] [blame] | 81 | {"MCP9600", I2CDeviceType{"mcp9600", false}}, |
Zev Weiss | d29f8aa | 2022-08-03 16:24:59 -0700 | [diff] [blame] | 82 | {"NCT6779", I2CDeviceType{"nct6779", true}}, |
| 83 | {"NCT7802", I2CDeviceType{"nct7802", true}}, |
Potin Lai | fb011cc | 2024-02-22 19:51:48 +0800 | [diff] [blame] | 84 | {"PT5161L", I2CDeviceType{"pt5161l", true}}, |
Zev Weiss | d29f8aa | 2022-08-03 16:24:59 -0700 | [diff] [blame] | 85 | {"SBTSI", I2CDeviceType{"sbtsi", true}}, |
| 86 | {"SI7020", I2CDeviceType{"si7020", false}}, |
Tim Lee | 9b0a6f6 | 2022-12-23 14:47:02 +0800 | [diff] [blame] | 87 | {"TMP100", I2CDeviceType{"tmp100", true}}, |
Potin Lai | 5f917fc | 2025-05-29 14:13:10 +0800 | [diff] [blame^] | 88 | {"TMP1075", I2CDeviceType{"tmp1075", true}}, |
Zev Weiss | d29f8aa | 2022-08-03 16:24:59 -0700 | [diff] [blame] | 89 | {"TMP112", I2CDeviceType{"tmp112", true}}, |
| 90 | {"TMP175", I2CDeviceType{"tmp175", true}}, |
Chris Sides | 4080611 | 2025-02-27 12:06:08 -0600 | [diff] [blame] | 91 | {"TMP411", I2CDeviceType{"tmp411", true}}, |
Zev Weiss | d29f8aa | 2022-08-03 16:24:59 -0700 | [diff] [blame] | 92 | {"TMP421", I2CDeviceType{"tmp421", true}}, |
Andrew Geissler | 8800c04 | 2024-07-23 17:19:17 -0300 | [diff] [blame] | 93 | {"TMP432", I2CDeviceType{"tmp432", true}}, |
Zev Weiss | d29f8aa | 2022-08-03 16:24:59 -0700 | [diff] [blame] | 94 | {"TMP441", I2CDeviceType{"tmp441", true}}, |
Potin Lai | 0674788 | 2025-05-27 15:46:26 +0800 | [diff] [blame] | 95 | {"TMP451", I2CDeviceType{"tmp451", true}}, |
Khang Kieu | f4c3fad | 2023-11-27 22:39:01 +0000 | [diff] [blame] | 96 | {"TMP461", I2CDeviceType{"tmp461", true}}, |
Hieu Huynh | 9a7db6a | 2023-06-19 11:02:07 +0000 | [diff] [blame] | 97 | {"TMP464", I2CDeviceType{"tmp464", true}}, |
Hieu Huynh | 1048077 | 2024-09-13 11:23:46 +0000 | [diff] [blame] | 98 | {"TMP468", I2CDeviceType{"tmp468", true}}, |
Zev Weiss | d29f8aa | 2022-08-03 16:24:59 -0700 | [diff] [blame] | 99 | {"TMP75", I2CDeviceType{"tmp75", true}}, |
| 100 | {"W83773G", I2CDeviceType{"w83773g", true}}, |
| 101 | }; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 102 | |
Patrick Williams | 556e04b | 2025-02-01 08:22:22 -0500 | [diff] [blame] | 103 | static struct SensorParams getSensorParameters( |
| 104 | const std::filesystem::path& path) |
Bruce Mitchell | 544e7dc | 2021-07-29 18:05:49 -0500 | [diff] [blame] | 105 | { |
| 106 | // offset is to default to 0 and scale to 1, see lore |
| 107 | // https://lore.kernel.org/linux-iio/5c79425f-6e88-36b6-cdfe-4080738d039f@metafoo.de/ |
Patrick Williams | 779c96a | 2023-05-10 07:50:42 -0500 | [diff] [blame] | 108 | struct SensorParams tmpSensorParameters = { |
| 109 | .minValue = minValueTemperature, |
| 110 | .maxValue = maxValueTemperature, |
| 111 | .offsetValue = 0.0, |
| 112 | .scaleValue = 1.0, |
| 113 | .units = sensor_paths::unitDegreesC, |
| 114 | .typeName = "temperature"}; |
Bruce Mitchell | 544e7dc | 2021-07-29 18:05:49 -0500 | [diff] [blame] | 115 | |
| 116 | // For IIO RAW sensors we get a raw_value, an offset, and scale |
| 117 | // to compute the value = (raw_value + offset) * scale |
| 118 | // with a _raw IIO device we need to get the |
| 119 | // offsetValue and scaleValue from the driver |
| 120 | // these are used to compute the reading in |
| 121 | // units that have yet to be scaled for D-Bus. |
| 122 | const std::string pathStr = path.string(); |
| 123 | if (pathStr.ends_with("_raw")) |
| 124 | { |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 125 | std::string pathOffsetStr = |
| 126 | pathStr.substr(0, pathStr.size() - 4) + "_offset"; |
Bruce Mitchell | 544e7dc | 2021-07-29 18:05:49 -0500 | [diff] [blame] | 127 | std::optional<double> tmpOffsetValue = readFile(pathOffsetStr, 1.0); |
| 128 | // In case there is nothing to read skip this device |
| 129 | // This is not an error condition see lore |
| 130 | // https://lore.kernel.org/linux-iio/5c79425f-6e88-36b6-cdfe-4080738d039f@metafoo.de/ |
| 131 | if (tmpOffsetValue) |
| 132 | { |
| 133 | tmpSensorParameters.offsetValue = *tmpOffsetValue; |
| 134 | } |
| 135 | |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 136 | std::string pathScaleStr = |
| 137 | pathStr.substr(0, pathStr.size() - 4) + "_scale"; |
Bruce Mitchell | 544e7dc | 2021-07-29 18:05:49 -0500 | [diff] [blame] | 138 | std::optional<double> tmpScaleValue = readFile(pathScaleStr, 1.0); |
| 139 | // In case there is nothing to read skip this device |
| 140 | // This is not an error condition see lore |
| 141 | // https://lore.kernel.org/linux-iio/5c79425f-6e88-36b6-cdfe-4080738d039f@metafoo.de/ |
| 142 | if (tmpScaleValue) |
| 143 | { |
| 144 | tmpSensorParameters.scaleValue = *tmpScaleValue; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | // Temperatures are read in milli degrees Celsius, we need |
| 149 | // degrees Celsius. Pressures are read in kilopascal, we need |
| 150 | // Pascals. On D-Bus for Open BMC we use the International |
| 151 | // System of Units without prefixes. Links to the kernel |
| 152 | // documentation: |
| 153 | // https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface |
| 154 | // https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-bus-iio |
| 155 | if (path.filename() == "in_pressure_input" || |
| 156 | path.filename() == "in_pressure_raw") |
| 157 | { |
| 158 | tmpSensorParameters.minValue = minValuePressure; |
| 159 | tmpSensorParameters.maxValue = maxValuePressure; |
| 160 | // Pressures are read in kilopascal, we need Pascals. |
| 161 | tmpSensorParameters.scaleValue *= 1000.0; |
| 162 | tmpSensorParameters.typeName = "pressure"; |
Bruce Mitchell | 5a86e56 | 2021-12-10 12:26:22 -0600 | [diff] [blame] | 163 | tmpSensorParameters.units = sensor_paths::unitPascals; |
Bruce Mitchell | 544e7dc | 2021-07-29 18:05:49 -0500 | [diff] [blame] | 164 | } |
Bruce Mitchell | 3ec41c5 | 2021-12-10 16:05:17 -0600 | [diff] [blame] | 165 | else if (path.filename() == "in_humidityrelative_input" || |
| 166 | path.filename() == "in_humidityrelative_raw") |
| 167 | { |
| 168 | tmpSensorParameters.minValue = minValueRelativeHumidity; |
| 169 | tmpSensorParameters.maxValue = maxValueRelativeHumidity; |
| 170 | // Relative Humidity are read in milli-percent, we need percent. |
| 171 | tmpSensorParameters.scaleValue *= 0.001; |
| 172 | tmpSensorParameters.typeName = "humidity"; |
Potin Lai | a9c1bec | 2024-04-19 08:35:56 +0800 | [diff] [blame] | 173 | tmpSensorParameters.units = sensor_paths::unitPercentRH; |
Bruce Mitchell | 3ec41c5 | 2021-12-10 16:05:17 -0600 | [diff] [blame] | 174 | } |
Bruce Mitchell | 544e7dc | 2021-07-29 18:05:49 -0500 | [diff] [blame] | 175 | else |
| 176 | { |
| 177 | // Temperatures are read in milli degrees Celsius, |
| 178 | // we need degrees Celsius. |
| 179 | tmpSensorParameters.scaleValue *= 0.001; |
| 180 | } |
| 181 | |
| 182 | return tmpSensorParameters; |
| 183 | } |
| 184 | |
Jayashree Dhanapal | 9f3a74e | 2022-01-06 12:05:06 +0530 | [diff] [blame] | 185 | struct SensorConfigKey |
| 186 | { |
| 187 | uint64_t bus; |
| 188 | uint64_t addr; |
| 189 | bool operator<(const SensorConfigKey& other) const |
| 190 | { |
| 191 | if (bus != other.bus) |
| 192 | { |
| 193 | return bus < other.bus; |
| 194 | } |
| 195 | return addr < other.addr; |
| 196 | } |
| 197 | }; |
| 198 | |
| 199 | struct SensorConfig |
| 200 | { |
| 201 | std::string sensorPath; |
| 202 | SensorData sensorData; |
| 203 | std::string interface; |
| 204 | SensorBaseConfigMap config; |
| 205 | std::vector<std::string> name; |
| 206 | }; |
| 207 | |
| 208 | using SensorConfigMap = |
| 209 | boost::container::flat_map<SensorConfigKey, SensorConfig>; |
| 210 | |
Patrick Williams | 556e04b | 2025-02-01 08:22:22 -0500 | [diff] [blame] | 211 | static SensorConfigMap buildSensorConfigMap( |
| 212 | const ManagedObjectType& sensorConfigs) |
Jayashree Dhanapal | 9f3a74e | 2022-01-06 12:05:06 +0530 | [diff] [blame] | 213 | { |
| 214 | SensorConfigMap configMap; |
Zev Weiss | a180833 | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 215 | for (const auto& [path, cfgData] : sensorConfigs) |
Jayashree Dhanapal | 9f3a74e | 2022-01-06 12:05:06 +0530 | [diff] [blame] | 216 | { |
Zev Weiss | a180833 | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 217 | for (const auto& [intf, cfg] : cfgData) |
Jayashree Dhanapal | 9f3a74e | 2022-01-06 12:05:06 +0530 | [diff] [blame] | 218 | { |
Jayashree Dhanapal | 9f3a74e | 2022-01-06 12:05:06 +0530 | [diff] [blame] | 219 | auto busCfg = cfg.find("Bus"); |
| 220 | auto addrCfg = cfg.find("Address"); |
| 221 | if ((busCfg == cfg.end()) || (addrCfg == cfg.end())) |
| 222 | { |
Jayashree Dhanapal | 9f3a74e | 2022-01-06 12:05:06 +0530 | [diff] [blame] | 223 | continue; |
| 224 | } |
| 225 | |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 226 | if ((std::get_if<uint64_t>(&busCfg->second) == nullptr) || |
| 227 | (std::get_if<uint64_t>(&addrCfg->second) == nullptr)) |
Jayashree Dhanapal | 9f3a74e | 2022-01-06 12:05:06 +0530 | [diff] [blame] | 228 | { |
George Liu | 8b06518 | 2025-02-20 14:08:47 +0800 | [diff] [blame] | 229 | lg2::error("'{PATH}' Bus or Address invalid", "PATH", path.str); |
Jayashree Dhanapal | 9f3a74e | 2022-01-06 12:05:06 +0530 | [diff] [blame] | 230 | continue; |
| 231 | } |
| 232 | |
| 233 | std::vector<std::string> hwmonNames; |
| 234 | auto nameCfg = cfg.find("Name"); |
| 235 | if (nameCfg != cfg.end()) |
| 236 | { |
| 237 | hwmonNames.push_back(std::get<std::string>(nameCfg->second)); |
| 238 | size_t i = 1; |
| 239 | while (true) |
| 240 | { |
| 241 | auto sensorNameCfg = cfg.find("Name" + std::to_string(i)); |
| 242 | if (sensorNameCfg == cfg.end()) |
| 243 | { |
| 244 | break; |
| 245 | } |
| 246 | hwmonNames.push_back( |
| 247 | std::get<std::string>(sensorNameCfg->second)); |
| 248 | i++; |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | SensorConfigKey key = {std::get<uint64_t>(busCfg->second), |
| 253 | std::get<uint64_t>(addrCfg->second)}; |
Zev Weiss | a180833 | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 254 | SensorConfig val = {path.str, cfgData, intf, cfg, hwmonNames}; |
Jayashree Dhanapal | 9f3a74e | 2022-01-06 12:05:06 +0530 | [diff] [blame] | 255 | |
| 256 | auto [it, inserted] = configMap.emplace(key, std::move(val)); |
| 257 | if (!inserted) |
| 258 | { |
George Liu | 8b06518 | 2025-02-20 14:08:47 +0800 | [diff] [blame] | 259 | lg2::error( |
| 260 | "'{PATH}': ignoring duplicate entry for '{BUS}', '{ADDR}'", |
| 261 | "PATH", path.str, "BUS", key.bus, "ADDR", lg2::hex, |
| 262 | key.addr); |
Jayashree Dhanapal | 9f3a74e | 2022-01-06 12:05:06 +0530 | [diff] [blame] | 263 | } |
| 264 | } |
| 265 | } |
| 266 | return configMap; |
| 267 | } |
| 268 | |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 269 | void createSensors( |
Ed Tanous | 1f97863 | 2023-02-28 18:16:39 -0800 | [diff] [blame] | 270 | boost::asio::io_context& io, sdbusplus::asio::object_server& objectServer, |
Yong Li | f3fd191 | 2020-03-25 21:35:23 +0800 | [diff] [blame] | 271 | boost::container::flat_map<std::string, std::shared_ptr<HwmonTempSensor>>& |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 272 | sensors, |
| 273 | std::shared_ptr<sdbusplus::asio::connection>& dbusConnection, |
James Feist | 5591cf08 | 2020-07-15 16:44:54 -0700 | [diff] [blame] | 274 | const std::shared_ptr<boost::container::flat_set<std::string>>& |
Zev Weiss | a1456c4 | 2022-07-18 16:59:35 -0700 | [diff] [blame] | 275 | sensorsChanged, |
| 276 | bool activateOnly) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 277 | { |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 278 | auto getter = std::make_shared<GetSensorConfiguration>( |
| 279 | dbusConnection, |
Zev Weiss | a1456c4 | 2022-07-18 16:59:35 -0700 | [diff] [blame] | 280 | [&io, &objectServer, &sensors, &dbusConnection, sensorsChanged, |
| 281 | activateOnly](const ManagedObjectType& sensorConfigurations) { |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 282 | bool firstScan = sensorsChanged == nullptr; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 283 | |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 284 | SensorConfigMap configMap = |
| 285 | buildSensorConfigMap(sensorConfigurations); |
Jayashree Dhanapal | 9f3a74e | 2022-01-06 12:05:06 +0530 | [diff] [blame] | 286 | |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 287 | auto devices = |
| 288 | instantiateDevices(sensorConfigurations, sensors, sensorTypes); |
Zev Weiss | a1456c4 | 2022-07-18 16:59:35 -0700 | [diff] [blame] | 289 | |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 290 | // IIO _raw devices look like this on sysfs: |
| 291 | // /sys/bus/iio/devices/iio:device0/in_temp_raw |
| 292 | // /sys/bus/iio/devices/iio:device0/in_temp_offset |
| 293 | // /sys/bus/iio/devices/iio:device0/in_temp_scale |
| 294 | // |
| 295 | // Other IIO devices look like this on sysfs: |
| 296 | // /sys/bus/iio/devices/iio:device1/in_temp_input |
| 297 | // /sys/bus/iio/devices/iio:device1/in_pressure_input |
Ed Tanous | 2e46696 | 2025-01-30 10:59:49 -0800 | [diff] [blame] | 298 | std::vector<std::filesystem::path> paths; |
| 299 | std::filesystem::path root("/sys/bus/iio/devices"); |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 300 | findFiles(root, R"(in_temp\d*_(input|raw))", paths); |
| 301 | findFiles(root, R"(in_pressure\d*_(input|raw))", paths); |
| 302 | findFiles(root, R"(in_humidityrelative\d*_(input|raw))", paths); |
Ed Tanous | 2e46696 | 2025-01-30 10:59:49 -0800 | [diff] [blame] | 303 | findFiles(std::filesystem::path("/sys/class/hwmon"), |
| 304 | R"(temp\d+_input)", paths); |
Bruce Mitchell | 544e7dc | 2021-07-29 18:05:49 -0500 | [diff] [blame] | 305 | |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 306 | // iterate through all found temp and pressure sensors, |
| 307 | // and try to match them with configuration |
| 308 | for (auto& path : paths) |
James Feist | 37266ca | 2018-10-15 15:56:28 -0700 | [diff] [blame] | 309 | { |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 310 | std::smatch match; |
| 311 | const std::string pathStr = path.string(); |
| 312 | auto directory = path.parent_path(); |
Ed Tanous | 2e46696 | 2025-01-30 10:59:49 -0800 | [diff] [blame] | 313 | std::filesystem::path device; |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 314 | |
| 315 | std::string deviceName; |
| 316 | std::error_code ec; |
| 317 | if (pathStr.starts_with("/sys/bus/iio/devices")) |
Zhikui Ren | ae46396 | 2024-01-02 15:35:31 -0800 | [diff] [blame] | 318 | { |
Ed Tanous | 2e46696 | 2025-01-30 10:59:49 -0800 | [diff] [blame] | 319 | device = std::filesystem::canonical(directory, ec); |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 320 | if (ec) |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 321 | { |
George Liu | 8b06518 | 2025-02-20 14:08:47 +0800 | [diff] [blame] | 322 | lg2::error("Fail to find device in '{PATH}'", "PATH", |
| 323 | pathStr); |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 324 | continue; |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 325 | } |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 326 | deviceName = device.parent_path().stem(); |
Zev Weiss | a1456c4 | 2022-07-18 16:59:35 -0700 | [diff] [blame] | 327 | } |
| 328 | else |
| 329 | { |
Ed Tanous | 2e46696 | 2025-01-30 10:59:49 -0800 | [diff] [blame] | 330 | device = |
| 331 | std::filesystem::canonical(directory / "device", ec); |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 332 | if (ec) |
| 333 | { |
George Liu | 8b06518 | 2025-02-20 14:08:47 +0800 | [diff] [blame] | 334 | lg2::error("Fail to find device in '{PATH}'", "PATH", |
| 335 | pathStr); |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 336 | continue; |
| 337 | } |
| 338 | deviceName = device.stem(); |
Zev Weiss | a1456c4 | 2022-07-18 16:59:35 -0700 | [diff] [blame] | 339 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 340 | |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 341 | uint64_t bus = 0; |
| 342 | uint64_t addr = 0; |
| 343 | if (!getDeviceBusAddr(deviceName, bus, addr)) |
James Feist | 37266ca | 2018-10-15 15:56:28 -0700 | [diff] [blame] | 344 | { |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 345 | continue; |
| 346 | } |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 347 | |
| 348 | auto thisSensorParameters = getSensorParameters(path); |
| 349 | auto findSensorCfg = configMap.find({bus, addr}); |
| 350 | if (findSensorCfg == configMap.end()) |
| 351 | { |
| 352 | continue; |
| 353 | } |
| 354 | |
| 355 | const std::string& interfacePath = |
| 356 | findSensorCfg->second.sensorPath; |
| 357 | auto findI2CDev = devices.find(interfacePath); |
| 358 | |
| 359 | std::shared_ptr<I2CDevice> i2cDev; |
| 360 | if (findI2CDev != devices.end()) |
| 361 | { |
| 362 | // If we're only looking to activate newly-instantiated i2c |
| 363 | // devices and this sensor's underlying device was already |
| 364 | // there before this call, there's nothing more to do here. |
| 365 | if (activateOnly && !findI2CDev->second.second) |
| 366 | { |
| 367 | continue; |
| 368 | } |
| 369 | i2cDev = findI2CDev->second.first; |
| 370 | } |
| 371 | |
| 372 | const SensorData& sensorData = findSensorCfg->second.sensorData; |
| 373 | std::string sensorType = findSensorCfg->second.interface; |
| 374 | auto pos = sensorType.find_last_of('.'); |
| 375 | if (pos != std::string::npos) |
| 376 | { |
| 377 | sensorType = sensorType.substr(pos + 1); |
| 378 | } |
| 379 | const SensorBaseConfigMap& baseConfigMap = |
| 380 | findSensorCfg->second.config; |
| 381 | std::vector<std::string>& hwmonName = |
| 382 | findSensorCfg->second.name; |
| 383 | |
| 384 | // Temperature has "Name", pressure has "Name1" |
| 385 | auto findSensorName = baseConfigMap.find("Name"); |
| 386 | int index = 1; |
| 387 | if (thisSensorParameters.typeName == "pressure" || |
| 388 | thisSensorParameters.typeName == "humidity") |
| 389 | { |
| 390 | findSensorName = baseConfigMap.find("Name1"); |
| 391 | index = 2; |
| 392 | } |
| 393 | |
| 394 | if (findSensorName == baseConfigMap.end()) |
| 395 | { |
George Liu | 8b06518 | 2025-02-20 14:08:47 +0800 | [diff] [blame] | 396 | lg2::error( |
| 397 | "could not determine configuration name for '{NAME}'", |
| 398 | "NAME", deviceName); |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 399 | continue; |
| 400 | } |
| 401 | std::string sensorName = |
| 402 | std::get<std::string>(findSensorName->second); |
| 403 | // on rescans, only update sensors we were signaled by |
| 404 | auto findSensor = sensors.find(sensorName); |
| 405 | if (!firstScan && findSensor != sensors.end()) |
| 406 | { |
| 407 | bool found = false; |
| 408 | auto it = sensorsChanged->begin(); |
| 409 | while (it != sensorsChanged->end()) |
| 410 | { |
| 411 | if (it->ends_with(findSensor->second->name)) |
| 412 | { |
| 413 | it = sensorsChanged->erase(it); |
| 414 | findSensor->second = nullptr; |
| 415 | found = true; |
| 416 | break; |
| 417 | } |
| 418 | ++it; |
| 419 | } |
| 420 | if (!found) |
| 421 | { |
| 422 | continue; |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | std::vector<thresholds::Threshold> sensorThresholds; |
| 427 | |
| 428 | if (!parseThresholdsFromConfig(sensorData, sensorThresholds, |
| 429 | nullptr, &index)) |
| 430 | { |
George Liu | 8b06518 | 2025-02-20 14:08:47 +0800 | [diff] [blame] | 431 | lg2::error("error populating thresholds for " |
| 432 | "'{NAME}', index: '{INDEX}'", |
| 433 | "NAME", sensorName, "INDEX", index); |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | float pollRate = getPollRate(baseConfigMap, pollRateDefault); |
| 437 | PowerState readState = getPowerState(baseConfigMap); |
| 438 | |
| 439 | auto permitSet = getPermitSet(baseConfigMap); |
| 440 | auto& sensor = sensors[sensorName]; |
| 441 | if (!activateOnly) |
| 442 | { |
| 443 | sensor = nullptr; |
| 444 | } |
| 445 | auto hwmonFile = getFullHwmonFilePath(directory.string(), |
| 446 | "temp1", permitSet); |
| 447 | if (pathStr.starts_with("/sys/bus/iio/devices")) |
| 448 | { |
| 449 | hwmonFile = pathStr; |
| 450 | } |
Jason Ling | 100c20b | 2020-08-11 14:50:33 -0700 | [diff] [blame] | 451 | if (hwmonFile) |
| 452 | { |
Zev Weiss | a1456c4 | 2022-07-18 16:59:35 -0700 | [diff] [blame] | 453 | if (sensor != nullptr) |
| 454 | { |
| 455 | sensor->activate(*hwmonFile, i2cDev); |
| 456 | } |
| 457 | else |
| 458 | { |
| 459 | sensor = std::make_shared<HwmonTempSensor>( |
| 460 | *hwmonFile, sensorType, objectServer, |
| 461 | dbusConnection, io, sensorName, |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 462 | std::move(sensorThresholds), thisSensorParameters, |
Zev Weiss | a1456c4 | 2022-07-18 16:59:35 -0700 | [diff] [blame] | 463 | pollRate, interfacePath, readState, i2cDev); |
| 464 | sensor->setupRead(); |
| 465 | } |
Jason Ling | 100c20b | 2020-08-11 14:50:33 -0700 | [diff] [blame] | 466 | } |
Willy Tu | 9eb0cc3 | 2022-04-06 11:03:32 -0700 | [diff] [blame] | 467 | hwmonName.erase( |
| 468 | remove(hwmonName.begin(), hwmonName.end(), sensorName), |
| 469 | hwmonName.end()); |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 470 | |
| 471 | // Looking for keys like "Name1" for temp2_input, |
| 472 | // "Name2" for temp3_input, etc. |
| 473 | int i = 0; |
| 474 | while (true) |
| 475 | { |
| 476 | ++i; |
| 477 | auto findKey = |
| 478 | baseConfigMap.find("Name" + std::to_string(i)); |
| 479 | if (findKey == baseConfigMap.end()) |
| 480 | { |
| 481 | break; |
| 482 | } |
| 483 | std::string sensorName = |
| 484 | std::get<std::string>(findKey->second); |
| 485 | hwmonFile = getFullHwmonFilePath( |
| 486 | directory.string(), "temp" + std::to_string(i + 1), |
| 487 | permitSet); |
| 488 | if (pathStr.starts_with("/sys/bus/iio/devices")) |
| 489 | { |
| 490 | continue; |
| 491 | } |
| 492 | if (hwmonFile) |
| 493 | { |
| 494 | // To look up thresholds for these additional sensors, |
| 495 | // match on the Index property in the threshold data |
| 496 | // where the index comes from the sysfs file we're on, |
| 497 | // i.e. index = 2 for temp2_input. |
| 498 | int index = i + 1; |
| 499 | std::vector<thresholds::Threshold> thresholds; |
| 500 | |
| 501 | if (!parseThresholdsFromConfig(sensorData, thresholds, |
| 502 | nullptr, &index)) |
| 503 | { |
George Liu | 8b06518 | 2025-02-20 14:08:47 +0800 | [diff] [blame] | 504 | lg2::error("error populating thresholds for " |
| 505 | "'{NAME}', index: '{INDEX}'", |
| 506 | "NAME", sensorName, "INDEX", index); |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | auto& sensor = sensors[sensorName]; |
| 510 | if (!activateOnly) |
| 511 | { |
| 512 | sensor = nullptr; |
| 513 | } |
| 514 | |
| 515 | if (sensor != nullptr) |
| 516 | { |
| 517 | sensor->activate(*hwmonFile, i2cDev); |
| 518 | } |
| 519 | else |
| 520 | { |
| 521 | sensor = std::make_shared<HwmonTempSensor>( |
| 522 | *hwmonFile, sensorType, objectServer, |
| 523 | dbusConnection, io, sensorName, |
| 524 | std::move(thresholds), thisSensorParameters, |
| 525 | pollRate, interfacePath, readState, i2cDev); |
| 526 | sensor->setupRead(); |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | hwmonName.erase( |
| 531 | remove(hwmonName.begin(), hwmonName.end(), sensorName), |
| 532 | hwmonName.end()); |
| 533 | } |
| 534 | if (hwmonName.empty()) |
| 535 | { |
| 536 | configMap.erase(findSensorCfg); |
| 537 | } |
James Feist | df51515 | 2019-09-18 16:40:40 -0700 | [diff] [blame] | 538 | } |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 539 | }); |
Zev Weiss | d29f8aa | 2022-08-03 16:24:59 -0700 | [diff] [blame] | 540 | std::vector<std::string> types(sensorTypes.size()); |
| 541 | for (const auto& [type, dt] : sensorTypes) |
| 542 | { |
| 543 | types.push_back(type); |
| 544 | } |
| 545 | getter->getConfiguration(types); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 546 | } |
| 547 | |
Matt Spinler | 20bf2c1 | 2021-09-14 11:07:07 -0500 | [diff] [blame] | 548 | void interfaceRemoved( |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 549 | sdbusplus::message_t& message, |
Matt Spinler | 20bf2c1 | 2021-09-14 11:07:07 -0500 | [diff] [blame] | 550 | boost::container::flat_map<std::string, std::shared_ptr<HwmonTempSensor>>& |
| 551 | sensors) |
| 552 | { |
| 553 | if (message.is_method_error()) |
| 554 | { |
George Liu | 8b06518 | 2025-02-20 14:08:47 +0800 | [diff] [blame] | 555 | lg2::error("interfacesRemoved callback method error"); |
Matt Spinler | 20bf2c1 | 2021-09-14 11:07:07 -0500 | [diff] [blame] | 556 | return; |
| 557 | } |
| 558 | |
| 559 | sdbusplus::message::object_path path; |
| 560 | std::vector<std::string> interfaces; |
| 561 | |
| 562 | message.read(path, interfaces); |
| 563 | |
| 564 | // If the xyz.openbmc_project.Confguration.X interface was removed |
| 565 | // for one or more sensors, delete those sensor objects. |
| 566 | auto sensorIt = sensors.begin(); |
| 567 | while (sensorIt != sensors.end()) |
| 568 | { |
Patrick Rudolph | 6289f5a | 2023-09-22 11:32:54 +0200 | [diff] [blame] | 569 | if (sensorIt->second && (sensorIt->second->configurationPath == path) && |
Matt Spinler | 20bf2c1 | 2021-09-14 11:07:07 -0500 | [diff] [blame] | 570 | (std::find(interfaces.begin(), interfaces.end(), |
Matt Spinler | 55832f3 | 2023-06-07 10:24:00 -0500 | [diff] [blame] | 571 | sensorIt->second->configInterface) != interfaces.end())) |
Matt Spinler | 20bf2c1 | 2021-09-14 11:07:07 -0500 | [diff] [blame] | 572 | { |
| 573 | sensorIt = sensors.erase(sensorIt); |
| 574 | } |
| 575 | else |
| 576 | { |
| 577 | sensorIt++; |
| 578 | } |
| 579 | } |
| 580 | } |
| 581 | |
Zev Weiss | a1456c4 | 2022-07-18 16:59:35 -0700 | [diff] [blame] | 582 | static void powerStateChanged( |
| 583 | PowerState type, bool newState, |
| 584 | boost::container::flat_map<std::string, std::shared_ptr<HwmonTempSensor>>& |
| 585 | sensors, |
Ed Tanous | 1f97863 | 2023-02-28 18:16:39 -0800 | [diff] [blame] | 586 | boost::asio::io_context& io, sdbusplus::asio::object_server& objectServer, |
Zev Weiss | a1456c4 | 2022-07-18 16:59:35 -0700 | [diff] [blame] | 587 | std::shared_ptr<sdbusplus::asio::connection>& dbusConnection) |
| 588 | { |
| 589 | if (newState) |
| 590 | { |
| 591 | createSensors(io, objectServer, sensors, dbusConnection, nullptr, true); |
| 592 | } |
| 593 | else |
| 594 | { |
| 595 | for (auto& [path, sensor] : sensors) |
| 596 | { |
| 597 | if (sensor != nullptr && sensor->readState == type) |
| 598 | { |
| 599 | sensor->deactivate(); |
| 600 | } |
| 601 | } |
| 602 | } |
| 603 | } |
| 604 | |
James Feist | b6c0b91 | 2019-07-09 12:21:44 -0700 | [diff] [blame] | 605 | int main() |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 606 | { |
Ed Tanous | 1f97863 | 2023-02-28 18:16:39 -0800 | [diff] [blame] | 607 | boost::asio::io_context io; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 608 | auto systemBus = std::make_shared<sdbusplus::asio::connection>(io); |
Ed Tanous | 14ed5e9 | 2022-07-12 15:50:23 -0700 | [diff] [blame] | 609 | sdbusplus::asio::object_server objectServer(systemBus, true); |
| 610 | objectServer.add_manager("/xyz/openbmc_project/sensors"); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 611 | systemBus->request_name("xyz.openbmc_project.HwmonTempSensor"); |
Ed Tanous | 14ed5e9 | 2022-07-12 15:50:23 -0700 | [diff] [blame] | 612 | |
Yong Li | f3fd191 | 2020-03-25 21:35:23 +0800 | [diff] [blame] | 613 | boost::container::flat_map<std::string, std::shared_ptr<HwmonTempSensor>> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 614 | sensors; |
James Feist | 5591cf08 | 2020-07-15 16:44:54 -0700 | [diff] [blame] | 615 | auto sensorsChanged = |
| 616 | std::make_shared<boost::container::flat_set<std::string>>(); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 617 | |
Zev Weiss | a1456c4 | 2022-07-18 16:59:35 -0700 | [diff] [blame] | 618 | auto powerCallBack = [&sensors, &io, &objectServer, |
| 619 | &systemBus](PowerState type, bool state) { |
| 620 | powerStateChanged(type, state, sensors, io, objectServer, systemBus); |
| 621 | }; |
| 622 | setupPowerMatchCallback(systemBus, powerCallBack); |
| 623 | |
Ed Tanous | 83db50c | 2023-03-01 10:20:24 -0800 | [diff] [blame] | 624 | boost::asio::post(io, [&]() { |
Zev Weiss | a1456c4 | 2022-07-18 16:59:35 -0700 | [diff] [blame] | 625 | createSensors(io, objectServer, sensors, systemBus, nullptr, false); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 626 | }); |
| 627 | |
Ed Tanous | 9b4a20e | 2022-09-06 08:47:11 -0700 | [diff] [blame] | 628 | boost::asio::steady_timer filterTimer(io); |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 629 | std::function<void(sdbusplus::message_t&)> eventHandler = |
| 630 | [&](sdbusplus::message_t& message) { |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 631 | if (message.is_method_error()) |
| 632 | { |
George Liu | 8b06518 | 2025-02-20 14:08:47 +0800 | [diff] [blame] | 633 | lg2::error("callback method error"); |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 634 | return; |
| 635 | } |
| 636 | sensorsChanged->insert(message.get_path()); |
| 637 | // this implicitly cancels the timer |
| 638 | filterTimer.expires_after(std::chrono::seconds(1)); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 639 | |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 640 | filterTimer.async_wait([&](const boost::system::error_code& ec) { |
| 641 | if (ec == boost::asio::error::operation_aborted) |
| 642 | { |
| 643 | /* we were canceled*/ |
| 644 | return; |
| 645 | } |
| 646 | if (ec) |
| 647 | { |
George Liu | 8b06518 | 2025-02-20 14:08:47 +0800 | [diff] [blame] | 648 | lg2::error("timer error"); |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 649 | return; |
| 650 | } |
| 651 | createSensors(io, objectServer, sensors, systemBus, |
| 652 | sensorsChanged, false); |
| 653 | }); |
| 654 | }; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 655 | |
Zev Weiss | 214d971 | 2022-08-12 12:54:31 -0700 | [diff] [blame] | 656 | std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches = |
| 657 | setupPropertiesChangedMatches(*systemBus, sensorTypes, eventHandler); |
Bruce Lee | 1263c3d | 2021-06-04 15:16:33 +0800 | [diff] [blame] | 658 | setupManufacturingModeMatch(*systemBus); |
Matt Spinler | 20bf2c1 | 2021-09-14 11:07:07 -0500 | [diff] [blame] | 659 | |
| 660 | // Watch for entity-manager to remove configuration interfaces |
| 661 | // so the corresponding sensors can be removed. |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 662 | auto ifaceRemovedMatch = std::make_unique<sdbusplus::bus::match_t>( |
| 663 | static_cast<sdbusplus::bus_t&>(*systemBus), |
Matt Spinler | 20bf2c1 | 2021-09-14 11:07:07 -0500 | [diff] [blame] | 664 | "type='signal',member='InterfacesRemoved',arg0path='" + |
| 665 | std::string(inventoryPath) + "/'", |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 666 | [&sensors](sdbusplus::message_t& msg) { |
Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 667 | interfaceRemoved(msg, sensors); |
| 668 | }); |
Matt Spinler | 20bf2c1 | 2021-09-14 11:07:07 -0500 | [diff] [blame] | 669 | |
| 670 | matches.emplace_back(std::move(ifaceRemovedMatch)); |
| 671 | |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 672 | io.run(); |
| 673 | } |