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