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 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 17 | #include <ADCSensor.hpp> |
| 18 | #include <Utils.hpp> |
| 19 | #include <VariantVisitors.hpp> |
James Feist | b83bb2b | 2019-05-31 12:31:23 -0700 | [diff] [blame] | 20 | #include <boost/algorithm/string/case_conv.hpp> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 21 | #include <boost/algorithm/string/predicate.hpp> |
| 22 | #include <boost/algorithm/string/replace.hpp> |
| 23 | #include <boost/container/flat_set.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 24 | #include <sdbusplus/asio/connection.hpp> |
| 25 | #include <sdbusplus/asio/object_server.hpp> |
| 26 | #include <sdbusplus/bus/match.hpp> |
| 27 | |
James Feist | 24f02f2 | 2019-04-15 11:05:39 -0700 | [diff] [blame] | 28 | #include <filesystem> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 29 | #include <fstream> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 30 | #include <functional> |
| 31 | #include <memory> |
Zhu, Yunge | a5b1bbc | 2019-04-09 19:49:36 -0400 | [diff] [blame] | 32 | #include <optional> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 33 | #include <regex> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 34 | #include <string> |
| 35 | #include <variant> |
| 36 | #include <vector> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 37 | |
Jeff Lin | d9cd704 | 2020-11-20 15:49:28 +0800 | [diff] [blame] | 38 | static constexpr float pollRateDefault = 0.5; |
Zev Weiss | f72eb83 | 2021-06-25 05:55:08 +0000 | [diff] [blame] | 39 | static constexpr float gpioBridgeSetupTimeDefault = 0.02; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 40 | |
James Feist | cf3bce6 | 2019-01-08 10:07:19 -0800 | [diff] [blame] | 41 | namespace fs = std::filesystem; |
James Feist | 3eb8262 | 2019-02-08 13:10:22 -0800 | [diff] [blame] | 42 | |
Brandon Kim | 6655823 | 2021-11-09 16:53:08 -0800 | [diff] [blame] | 43 | static constexpr auto sensorTypes{ |
| 44 | std::to_array<const char*>({"xyz.openbmc_project.Configuration.ADC"})}; |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 45 | static std::regex inputRegex(R"(in(\d+)_input)"); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 46 | |
James Feist | b83bb2b | 2019-05-31 12:31:23 -0700 | [diff] [blame] | 47 | static boost::container::flat_map<size_t, bool> cpuPresence; |
| 48 | |
Matt Spinler | 6ad74d9 | 2022-03-01 10:56:46 -0600 | [diff] [blame] | 49 | enum class UpdateType |
| 50 | { |
| 51 | init, |
| 52 | cpuPresenceChange |
| 53 | }; |
| 54 | |
James Feist | 08aec6f | 2019-01-30 16:17:04 -0800 | [diff] [blame] | 55 | // filter out adc from any other voltage sensor |
| 56 | bool isAdc(const fs::path& parentPath) |
| 57 | { |
| 58 | fs::path namePath = parentPath / "name"; |
| 59 | |
| 60 | std::ifstream nameFile(namePath); |
| 61 | if (!nameFile.good()) |
| 62 | { |
| 63 | std::cerr << "Failure reading " << namePath.string() << "\n"; |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | std::string name; |
| 68 | std::getline(nameFile, name); |
| 69 | |
| 70 | return name == "iio_hwmon"; |
| 71 | } |
| 72 | |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 73 | void createSensors( |
| 74 | boost::asio::io_service& io, sdbusplus::asio::object_server& objectServer, |
Yong Li | 1afda6b | 2020-04-09 19:24:13 +0800 | [diff] [blame] | 75 | boost::container::flat_map<std::string, std::shared_ptr<ADCSensor>>& |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 76 | sensors, |
| 77 | std::shared_ptr<sdbusplus::asio::connection>& dbusConnection, |
James Feist | 5591cf08 | 2020-07-15 16:44:54 -0700 | [diff] [blame] | 78 | const std::shared_ptr<boost::container::flat_set<std::string>>& |
Matt Spinler | 6ad74d9 | 2022-03-01 10:56:46 -0600 | [diff] [blame] | 79 | sensorsChanged, |
| 80 | UpdateType updateType) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 81 | { |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 82 | auto getter = std::make_shared<GetSensorConfiguration>( |
| 83 | dbusConnection, |
Matt Spinler | 6ad74d9 | 2022-03-01 10:56:46 -0600 | [diff] [blame] | 84 | [&io, &objectServer, &sensors, &dbusConnection, sensorsChanged, |
| 85 | updateType](const ManagedObjectType& sensorConfigurations) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 86 | bool firstScan = sensorsChanged == nullptr; |
| 87 | std::vector<fs::path> paths; |
| 88 | if (!findFiles(fs::path("/sys/class/hwmon"), R"(in\d+_input)", paths)) |
| 89 | { |
| 90 | std::cerr << "No adc sensors in system\n"; |
| 91 | return; |
| 92 | } |
| 93 | |
| 94 | // iterate through all found adc sensors, and try to match them with |
| 95 | // configuration |
| 96 | for (auto& path : paths) |
| 97 | { |
| 98 | if (!isAdc(path.parent_path())) |
James Feist | 08aec6f | 2019-01-30 16:17:04 -0800 | [diff] [blame] | 99 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 100 | continue; |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 101 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 102 | std::smatch match; |
| 103 | std::string pathStr = path.string(); |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 104 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 105 | std::regex_search(pathStr, match, inputRegex); |
| 106 | std::string indexStr = *(match.begin() + 1); |
| 107 | |
| 108 | auto directory = path.parent_path(); |
| 109 | // convert to 0 based |
| 110 | size_t index = std::stoul(indexStr) - 1; |
| 111 | |
| 112 | const SensorData* sensorData = nullptr; |
| 113 | const std::string* interfacePath = nullptr; |
| 114 | const std::pair<std::string, boost::container::flat_map< |
| 115 | std::string, BasicVariantType>>* |
| 116 | baseConfiguration = nullptr; |
| 117 | for (const std::pair<sdbusplus::message::object_path, SensorData>& |
| 118 | sensor : sensorConfigurations) |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 119 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 120 | // clear it out each loop |
| 121 | baseConfiguration = nullptr; |
| 122 | |
| 123 | // find base configuration |
| 124 | for (const char* type : sensorTypes) |
James Feist | 08aec6f | 2019-01-30 16:17:04 -0800 | [diff] [blame] | 125 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 126 | auto sensorBase = sensor.second.find(type); |
| 127 | if (sensorBase != sensor.second.end()) |
Jae Hyun Yoo | 12bbae0 | 2019-07-22 17:24:09 -0700 | [diff] [blame] | 128 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 129 | baseConfiguration = &(*sensorBase); |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 130 | break; |
| 131 | } |
| 132 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 133 | if (baseConfiguration == nullptr) |
| 134 | { |
| 135 | continue; |
| 136 | } |
| 137 | auto findIndex = baseConfiguration->second.find("Index"); |
| 138 | if (findIndex == baseConfiguration->second.end()) |
| 139 | { |
| 140 | std::cerr << "Base configuration missing Index" |
| 141 | << baseConfiguration->first << "\n"; |
| 142 | continue; |
| 143 | } |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 144 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 145 | unsigned int number = std::visit(VariantToUnsignedIntVisitor(), |
| 146 | findIndex->second); |
| 147 | |
| 148 | if (number != index) |
| 149 | { |
| 150 | continue; |
| 151 | } |
| 152 | |
| 153 | sensorData = &(sensor.second); |
| 154 | interfacePath = &(sensor.first.str); |
| 155 | break; |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 156 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 157 | if (sensorData == nullptr) |
| 158 | { |
| 159 | std::cerr << "failed to find match for " << path.string() |
| 160 | << "\n"; |
| 161 | continue; |
| 162 | } |
| 163 | |
| 164 | if (baseConfiguration == nullptr) |
| 165 | { |
| 166 | std::cerr << "error finding base configuration for" |
| 167 | << path.string() << "\n"; |
| 168 | continue; |
| 169 | } |
| 170 | |
| 171 | auto findSensorName = baseConfiguration->second.find("Name"); |
| 172 | if (findSensorName == baseConfiguration->second.end()) |
| 173 | { |
| 174 | std::cerr << "could not determine configuration name for " |
| 175 | << path.string() << "\n"; |
| 176 | continue; |
| 177 | } |
| 178 | std::string sensorName = |
| 179 | std::get<std::string>(findSensorName->second); |
| 180 | |
| 181 | // on rescans, only update sensors we were signaled by |
| 182 | auto findSensor = sensors.find(sensorName); |
| 183 | if (!firstScan && findSensor != sensors.end()) |
| 184 | { |
| 185 | bool found = false; |
| 186 | for (auto it = sensorsChanged->begin(); |
| 187 | it != sensorsChanged->end(); it++) |
| 188 | { |
| 189 | if (findSensor->second && |
| 190 | boost::ends_with(*it, findSensor->second->name)) |
| 191 | { |
| 192 | sensorsChanged->erase(it); |
| 193 | findSensor->second = nullptr; |
| 194 | found = true; |
| 195 | break; |
| 196 | } |
| 197 | } |
| 198 | if (!found) |
| 199 | { |
| 200 | continue; |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | auto findCPU = baseConfiguration->second.find("CPURequired"); |
| 205 | if (findCPU != baseConfiguration->second.end()) |
| 206 | { |
| 207 | size_t index = |
| 208 | std::visit(VariantToIntVisitor(), findCPU->second); |
| 209 | auto presenceFind = cpuPresence.find(index); |
| 210 | if (presenceFind == cpuPresence.end()) |
| 211 | { |
| 212 | continue; // no such cpu |
| 213 | } |
| 214 | if (!presenceFind->second) |
| 215 | { |
| 216 | continue; // cpu not installed |
| 217 | } |
| 218 | } |
| 219 | else if (updateType == UpdateType::cpuPresenceChange) |
| 220 | { |
| 221 | continue; |
| 222 | } |
| 223 | |
| 224 | std::vector<thresholds::Threshold> sensorThresholds; |
| 225 | if (!parseThresholdsFromConfig(*sensorData, sensorThresholds)) |
| 226 | { |
| 227 | std::cerr << "error populating thresholds for " << sensorName |
| 228 | << "\n"; |
| 229 | } |
| 230 | |
| 231 | auto findScaleFactor = |
| 232 | baseConfiguration->second.find("ScaleFactor"); |
| 233 | float scaleFactor = 1.0; |
| 234 | if (findScaleFactor != baseConfiguration->second.end()) |
| 235 | { |
| 236 | scaleFactor = std::visit(VariantToFloatVisitor(), |
| 237 | findScaleFactor->second); |
| 238 | // scaleFactor is used in division |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame^] | 239 | if (scaleFactor == 0.0F) |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 240 | { |
| 241 | scaleFactor = 1.0; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | auto findPollRate = baseConfiguration->second.find("PollRate"); |
| 246 | float pollRate = pollRateDefault; |
| 247 | if (findPollRate != baseConfiguration->second.end()) |
| 248 | { |
| 249 | pollRate = |
| 250 | std::visit(VariantToFloatVisitor(), findPollRate->second); |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame^] | 251 | if (pollRate <= 0.0F) |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 252 | { |
| 253 | pollRate = pollRateDefault; // polling time too short |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | auto findPowerOn = baseConfiguration->second.find("PowerState"); |
| 258 | PowerState readState = PowerState::always; |
| 259 | if (findPowerOn != baseConfiguration->second.end()) |
| 260 | { |
| 261 | std::string powerState = |
| 262 | std::visit(VariantToStringVisitor(), findPowerOn->second); |
| 263 | setReadState(powerState, readState); |
| 264 | } |
| 265 | |
| 266 | auto& sensor = sensors[sensorName]; |
| 267 | sensor = nullptr; |
| 268 | |
| 269 | std::optional<BridgeGpio> bridgeGpio; |
| 270 | for (const SensorBaseConfiguration& suppConfig : *sensorData) |
| 271 | { |
| 272 | if (suppConfig.first.find("BridgeGpio") != std::string::npos) |
| 273 | { |
| 274 | auto findName = suppConfig.second.find("Name"); |
| 275 | if (findName != suppConfig.second.end()) |
| 276 | { |
| 277 | std::string gpioName = std::visit( |
| 278 | VariantToStringVisitor(), findName->second); |
| 279 | |
| 280 | int polarity = gpiod::line::ACTIVE_HIGH; |
| 281 | auto findPolarity = suppConfig.second.find("Polarity"); |
| 282 | if (findPolarity != suppConfig.second.end()) |
| 283 | { |
| 284 | if (std::string("Low") == |
| 285 | std::visit(VariantToStringVisitor(), |
| 286 | findPolarity->second)) |
| 287 | { |
| 288 | polarity = gpiod::line::ACTIVE_LOW; |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | float setupTime = gpioBridgeSetupTimeDefault; |
| 293 | auto findSetupTime = |
| 294 | suppConfig.second.find("SetupTime"); |
| 295 | if (findSetupTime != suppConfig.second.end()) |
| 296 | { |
| 297 | setupTime = std::visit(VariantToFloatVisitor(), |
| 298 | findSetupTime->second); |
| 299 | } |
| 300 | |
| 301 | bridgeGpio = BridgeGpio(gpioName, polarity, setupTime); |
| 302 | } |
| 303 | |
| 304 | break; |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | sensor = std::make_shared<ADCSensor>( |
| 309 | path.string(), objectServer, dbusConnection, io, sensorName, |
| 310 | std::move(sensorThresholds), scaleFactor, pollRate, readState, |
| 311 | *interfacePath, std::move(bridgeGpio)); |
| 312 | sensor->setupRead(); |
| 313 | } |
Ed Tanous | 8a17c30 | 2021-09-02 15:07:11 -0700 | [diff] [blame] | 314 | }); |
James Feist | c71c119 | 2019-09-18 14:31:33 -0700 | [diff] [blame] | 315 | |
| 316 | getter->getConfiguration( |
| 317 | std::vector<std::string>{sensorTypes.begin(), sensorTypes.end()}); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 318 | } |
| 319 | |
James Feist | b6c0b91 | 2019-07-09 12:21:44 -0700 | [diff] [blame] | 320 | int main() |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 321 | { |
| 322 | boost::asio::io_service io; |
| 323 | auto systemBus = std::make_shared<sdbusplus::asio::connection>(io); |
| 324 | systemBus->request_name("xyz.openbmc_project.ADCSensor"); |
| 325 | sdbusplus::asio::object_server objectServer(systemBus); |
Yong Li | 1afda6b | 2020-04-09 19:24:13 +0800 | [diff] [blame] | 326 | boost::container::flat_map<std::string, std::shared_ptr<ADCSensor>> sensors; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 327 | std::vector<std::unique_ptr<sdbusplus::bus::match::match>> matches; |
James Feist | 5591cf08 | 2020-07-15 16:44:54 -0700 | [diff] [blame] | 328 | auto sensorsChanged = |
| 329 | std::make_shared<boost::container::flat_set<std::string>>(); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 330 | |
| 331 | io.post([&]() { |
Matt Spinler | 6ad74d9 | 2022-03-01 10:56:46 -0600 | [diff] [blame] | 332 | createSensors(io, objectServer, sensors, systemBus, nullptr, |
| 333 | UpdateType::init); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 334 | }); |
| 335 | |
| 336 | boost::asio::deadline_timer filterTimer(io); |
| 337 | std::function<void(sdbusplus::message::message&)> eventHandler = |
| 338 | [&](sdbusplus::message::message& message) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 339 | if (message.is_method_error()) |
| 340 | { |
| 341 | std::cerr << "callback method error\n"; |
| 342 | return; |
| 343 | } |
| 344 | sensorsChanged->insert(message.get_path()); |
| 345 | // this implicitly cancels the timer |
| 346 | filterTimer.expires_from_now(boost::posix_time::seconds(1)); |
| 347 | |
| 348 | filterTimer.async_wait([&](const boost::system::error_code& ec) { |
| 349 | if (ec == boost::asio::error::operation_aborted) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 350 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 351 | /* we were canceled*/ |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 352 | return; |
| 353 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 354 | if (ec) |
| 355 | { |
| 356 | std::cerr << "timer error\n"; |
| 357 | return; |
| 358 | } |
| 359 | createSensors(io, objectServer, sensors, systemBus, sensorsChanged, |
| 360 | UpdateType::init); |
| 361 | }); |
| 362 | }; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 363 | |
James Feist | b83bb2b | 2019-05-31 12:31:23 -0700 | [diff] [blame] | 364 | std::function<void(sdbusplus::message::message&)> cpuPresenceHandler = |
| 365 | [&](sdbusplus::message::message& message) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 366 | std::string path = message.get_path(); |
| 367 | boost::to_lower(path); |
James Feist | b83bb2b | 2019-05-31 12:31:23 -0700 | [diff] [blame] | 368 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 369 | if (path.rfind("cpu") == std::string::npos) |
| 370 | { |
| 371 | return; // not interested |
| 372 | } |
| 373 | size_t index = 0; |
| 374 | try |
| 375 | { |
| 376 | index = std::stoi(path.substr(path.size() - 1)); |
| 377 | } |
| 378 | catch (const std::invalid_argument&) |
| 379 | { |
| 380 | std::cerr << "Found invalid path " << path << "\n"; |
| 381 | return; |
| 382 | } |
| 383 | |
| 384 | std::string objectName; |
| 385 | boost::container::flat_map<std::string, std::variant<bool>> values; |
| 386 | message.read(objectName, values); |
| 387 | auto findPresence = values.find("Present"); |
| 388 | if (findPresence != values.end()) |
| 389 | { |
| 390 | cpuPresence[index] = std::get<bool>(findPresence->second); |
| 391 | } |
| 392 | |
| 393 | // this implicitly cancels the timer |
| 394 | filterTimer.expires_from_now(boost::posix_time::seconds(1)); |
| 395 | |
| 396 | filterTimer.async_wait([&](const boost::system::error_code& ec) { |
| 397 | if (ec == boost::asio::error::operation_aborted) |
James Feist | b83bb2b | 2019-05-31 12:31:23 -0700 | [diff] [blame] | 398 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 399 | /* we were canceled*/ |
James Feist | b83bb2b | 2019-05-31 12:31:23 -0700 | [diff] [blame] | 400 | return; |
| 401 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 402 | if (ec) |
James Feist | b83bb2b | 2019-05-31 12:31:23 -0700 | [diff] [blame] | 403 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 404 | std::cerr << "timer error\n"; |
| 405 | return; |
James Feist | b83bb2b | 2019-05-31 12:31:23 -0700 | [diff] [blame] | 406 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 407 | createSensors(io, objectServer, sensors, systemBus, nullptr, |
| 408 | UpdateType::cpuPresenceChange); |
| 409 | }); |
| 410 | }; |
James Feist | b83bb2b | 2019-05-31 12:31:23 -0700 | [diff] [blame] | 411 | |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 412 | for (const char* type : sensorTypes) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 413 | { |
| 414 | auto match = std::make_unique<sdbusplus::bus::match::match>( |
| 415 | static_cast<sdbusplus::bus::bus&>(*systemBus), |
| 416 | "type='signal',member='PropertiesChanged',path_namespace='" + |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 417 | std::string(inventoryPath) + "',arg0namespace='" + type + "'", |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 418 | eventHandler); |
| 419 | matches.emplace_back(std::move(match)); |
| 420 | } |
James Feist | b83bb2b | 2019-05-31 12:31:23 -0700 | [diff] [blame] | 421 | matches.emplace_back(std::make_unique<sdbusplus::bus::match::match>( |
| 422 | static_cast<sdbusplus::bus::bus&>(*systemBus), |
| 423 | "type='signal',member='PropertiesChanged',path_namespace='" + |
| 424 | std::string(cpuInventoryPath) + |
| 425 | "',arg0namespace='xyz.openbmc_project.Inventory.Item'", |
| 426 | cpuPresenceHandler)); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 427 | |
Bruce Lee | 1263c3d | 2021-06-04 15:16:33 +0800 | [diff] [blame] | 428 | setupManufacturingModeMatch(*systemBus); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 429 | io.run(); |
| 430 | } |