blob: a32d0549f14456c8891553a8dde2b1e418221827 [file] [log] [blame]
James Feist6714a252018-09-10 15:26:18 -07001/*
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 Tanous8a57ec02020-10-09 12:46:52 -070017#include <PwmSensor.hpp>
18#include <TachSensor.hpp>
19#include <Utils.hpp>
20#include <VariantVisitors.hpp>
James Feist6714a252018-09-10 15:26:18 -070021#include <boost/algorithm/string/predicate.hpp>
22#include <boost/algorithm/string/replace.hpp>
Patrick Venture96e97db2019-10-31 13:44:38 -070023#include <boost/container/flat_map.hpp>
James Feist6714a252018-09-10 15:26:18 -070024#include <boost/container/flat_set.hpp>
25#include <boost/lexical_cast.hpp>
James Feist38fb5982020-05-28 10:09:54 -070026#include <sdbusplus/asio/connection.hpp>
27#include <sdbusplus/asio/object_server.hpp>
28#include <sdbusplus/bus/match.hpp>
29
30#include <array>
James Feist24f02f22019-04-15 11:05:39 -070031#include <filesystem>
James Feist6714a252018-09-10 15:26:18 -070032#include <fstream>
Patrick Venture96e97db2019-10-31 13:44:38 -070033#include <functional>
34#include <memory>
35#include <optional>
James Feist6714a252018-09-10 15:26:18 -070036#include <regex>
Patrick Venture96e97db2019-10-31 13:44:38 -070037#include <string>
38#include <utility>
39#include <variant>
40#include <vector>
James Feist6714a252018-09-10 15:26:18 -070041
James Feistcf3bce62019-01-08 10:07:19 -080042namespace fs = std::filesystem;
James Feist3eb82622019-02-08 13:10:22 -080043
Yong Zhaoa3e8f2a2021-01-09 02:22:43 +000044// The following two structures need to be consistent
Brandon Kim66558232021-11-09 16:53:08 -080045static auto sensorTypes{std::to_array<const char*>(
46 {"xyz.openbmc_project.Configuration.AspeedFan",
47 "xyz.openbmc_project.Configuration.I2CFan",
48 "xyz.openbmc_project.Configuration.NuvotonFan"})};
Yong Zhaoa3e8f2a2021-01-09 02:22:43 +000049
50enum FanTypes
51{
52 aspeed = 0,
53 i2c,
54 nuvoton,
55 max,
56};
57
58static_assert(std::tuple_size<decltype(sensorTypes)>::value == FanTypes::max,
59 "sensorTypes element number is not equal to FanTypes number");
60
James Feistdc6c55f2018-10-31 12:53:20 -070061constexpr const char* redundancyConfiguration =
62 "xyz.openbmc_project.Configuration.FanRedundancy";
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -070063static std::regex inputRegex(R"(fan(\d+)_input)");
James Feist6714a252018-09-10 15:26:18 -070064
James Feistdc6c55f2018-10-31 12:53:20 -070065// todo: power supply fan redundancy
James Feist7b18b1e2019-05-14 13:42:09 -070066std::optional<RedundancySensor> systemRedundancy;
James Feist95b079b2018-11-21 09:28:00 -080067
68FanTypes getFanType(const fs::path& parentPath)
69{
70 fs::path linkPath = parentPath / "device";
71 std::string canonical = fs::read_symlink(linkPath);
Jae Hyun Yoo241356e2020-02-20 12:48:04 -080072 if (boost::ends_with(canonical, "1e786000.pwm-tacho-controller") ||
73 boost::ends_with(canonical, "1e610000.pwm-tacho-controller"))
James Feist95b079b2018-11-21 09:28:00 -080074 {
75 return FanTypes::aspeed;
76 }
Ed Tanous8a57ec02020-10-09 12:46:52 -070077 if (boost::ends_with(canonical, "f0103000.pwm-fan-controller"))
Peter Lundgren8843b622019-09-12 10:33:41 -070078 {
79 return FanTypes::nuvoton;
80 }
James Feist95b079b2018-11-21 09:28:00 -080081 // todo: will we need to support other types?
82 return FanTypes::i2c;
83}
Jeff Linabf91de2020-12-23 10:55:42 +080084void enablePwm(const fs::path& filePath)
85{
86 std::fstream enableFile(filePath, std::ios::in | std::ios::out);
87 if (!enableFile.good())
88 {
89 std::cerr << "Error read/write " << filePath << "\n";
90 return;
91 }
James Feistdc6c55f2018-10-31 12:53:20 -070092
Jeff Linabf91de2020-12-23 10:55:42 +080093 std::string regulateMode;
94 std::getline(enableFile, regulateMode);
95 if (regulateMode == "0")
96 {
97 enableFile << 1;
98 }
99}
Kuiying Wangd5407412020-09-09 16:06:56 +0800100void createRedundancySensor(
101 const boost::container::flat_map<std::string, std::unique_ptr<TachSensor>>&
102 sensors,
Ed Tanous8a57ec02020-10-09 12:46:52 -0700103 const std::shared_ptr<sdbusplus::asio::connection>& conn,
Kuiying Wangd5407412020-09-09 16:06:56 +0800104 sdbusplus::asio::object_server& objectServer)
105{
106
107 conn->async_method_call(
108 [&objectServer, &sensors](boost::system::error_code& ec,
Ed Tanous8a57ec02020-10-09 12:46:52 -0700109 const ManagedObjectType& managedObj) {
Kuiying Wangd5407412020-09-09 16:06:56 +0800110 if (ec)
111 {
112 std::cerr << "Error calling entity manager \n";
113 return;
114 }
115 for (const auto& pathPair : managedObj)
116 {
117 for (const auto& interfacePair : pathPair.second)
118 {
119 if (interfacePair.first == redundancyConfiguration)
120 {
121 // currently only support one
122 auto findCount =
123 interfacePair.second.find("AllowedFailures");
124 if (findCount == interfacePair.second.end())
125 {
126 std::cerr << "Malformed redundancy record \n";
127 return;
128 }
129 std::vector<std::string> sensorList;
130
131 for (const auto& sensor : sensors)
132 {
133 sensorList.push_back(
134 "/xyz/openbmc_project/sensors/fan_tach/" +
135 sensor.second->name);
136 }
137 systemRedundancy.reset();
138 systemRedundancy.emplace(RedundancySensor(
139 std::get<uint64_t>(findCount->second), sensorList,
140 objectServer, pathPair.first));
141
142 return;
143 }
144 }
145 }
146 },
147 "xyz.openbmc_project.EntityManager", "/",
148 "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
149}
150
James Feist6714a252018-09-10 15:26:18 -0700151void createSensors(
152 boost::asio::io_service& io, sdbusplus::asio::object_server& objectServer,
153 boost::container::flat_map<std::string, std::unique_ptr<TachSensor>>&
154 tachSensors,
155 boost::container::flat_map<std::string, std::unique_ptr<PwmSensor>>&
156 pwmSensors,
157 std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
James Feist5591cf082020-07-15 16:44:54 -0700158 const std::shared_ptr<boost::container::flat_set<std::string>>&
James Feistf27a55c2020-08-04 14:27:30 -0700159 sensorsChanged,
160 size_t retries = 0)
James Feist6714a252018-09-10 15:26:18 -0700161{
James Feistde5e9702019-09-18 16:13:02 -0700162 auto getter = std::make_shared<GetSensorConfiguration>(
163 dbusConnection,
Ed Tanous8a17c302021-09-02 15:07:11 -0700164 [&io, &objectServer, &tachSensors, &pwmSensors, &dbusConnection,
165 sensorsChanged](const ManagedObjectType& sensorConfigurations) {
James Feistde5e9702019-09-18 16:13:02 -0700166 bool firstScan = sensorsChanged == nullptr;
167 std::vector<fs::path> paths;
168 if (!findFiles(fs::path("/sys/class/hwmon"), R"(fan\d+_input)",
169 paths))
James Feist95b079b2018-11-21 09:28:00 -0800170 {
Yong Zhao77b3add2021-01-09 04:25:18 +0000171 std::cerr << "No fan sensors in system\n";
James Feistde5e9702019-09-18 16:13:02 -0700172 return;
James Feist95b079b2018-11-21 09:28:00 -0800173 }
James Feist6714a252018-09-10 15:26:18 -0700174
James Feistde5e9702019-09-18 16:13:02 -0700175 // iterate through all found fan sensors, and try to match them with
176 // configuration
177 for (const auto& path : paths)
James Feist6714a252018-09-10 15:26:18 -0700178 {
James Feistde5e9702019-09-18 16:13:02 -0700179 std::smatch match;
180 std::string pathStr = path.string();
181
182 std::regex_search(pathStr, match, inputRegex);
183 std::string indexStr = *(match.begin() + 1);
184
Yong Zhao77b3add2021-01-09 04:25:18 +0000185 fs::path directory = path.parent_path();
James Feistde5e9702019-09-18 16:13:02 -0700186 FanTypes fanType = getFanType(directory);
Yong Zhao77b3add2021-01-09 04:25:18 +0000187
James Feistde5e9702019-09-18 16:13:02 -0700188 // convert to 0 based
189 size_t index = std::stoul(indexStr) - 1;
190
Ed Tanousa771f6a2022-01-14 09:36:51 -0800191 const char* baseType = nullptr;
James Feistde5e9702019-09-18 16:13:02 -0700192 const SensorData* sensorData = nullptr;
193 const std::string* interfacePath = nullptr;
194 const SensorBaseConfiguration* baseConfiguration = nullptr;
195 for (const std::pair<sdbusplus::message::object_path,
196 SensorData>& sensor : sensorConfigurations)
James Feist95b079b2018-11-21 09:28:00 -0800197 {
James Feistde5e9702019-09-18 16:13:02 -0700198 // find the base of the configuration to see if indexes
199 // match
Yong Zhaoa3e8f2a2021-01-09 02:22:43 +0000200 auto sensorBaseFind =
201 sensor.second.find(sensorTypes[fanType]);
202 if (sensorBaseFind == sensor.second.end())
James Feistde5e9702019-09-18 16:13:02 -0700203 {
204 continue;
205 }
Zhikui Ren347dd4e2019-12-12 13:39:50 -0800206
Yong Zhaoa3e8f2a2021-01-09 02:22:43 +0000207 baseConfiguration = &(*sensorBaseFind);
208 interfacePath = &(sensor.first.str);
209 baseType = sensorTypes[fanType];
210
James Feistde5e9702019-09-18 16:13:02 -0700211 auto findIndex = baseConfiguration->second.find("Index");
212 if (findIndex == baseConfiguration->second.end())
213 {
214 std::cerr << baseConfiguration->first
215 << " missing index\n";
216 continue;
217 }
218 unsigned int configIndex = std::visit(
219 VariantToUnsignedIntVisitor(), findIndex->second);
220 if (configIndex != index)
221 {
222 continue;
223 }
224 if (fanType == FanTypes::aspeed ||
225 fanType == FanTypes::nuvoton)
226 {
227 // there will be only 1 aspeed or nuvoton sensor object
228 // in sysfs, we found the fan
229 sensorData = &(sensor.second);
230 break;
231 }
Ed Tanous8a57ec02020-10-09 12:46:52 -0700232 if (fanType == FanTypes::i2c)
James Feistde5e9702019-09-18 16:13:02 -0700233 {
Yong Zhaoadd46822021-01-09 04:52:36 +0000234 size_t bus = 0;
235 size_t address = 0;
236
237 std::string link =
238 fs::read_symlink(directory / "device").filename();
239
240 size_t findDash = link.find('-');
241 if (findDash == std::string::npos ||
242 link.size() <= findDash + 1)
243 {
244 std::cerr << "Error finding device from symlink";
245 }
246 bus = std::stoi(link.substr(0, findDash));
247 address =
248 std::stoi(link.substr(findDash + 1), nullptr, 16);
249
James Feistde5e9702019-09-18 16:13:02 -0700250 auto findBus = baseConfiguration->second.find("Bus");
251 auto findAddress =
252 baseConfiguration->second.find("Address");
253 if (findBus == baseConfiguration->second.end() ||
254 findAddress == baseConfiguration->second.end())
255 {
256 std::cerr << baseConfiguration->first
257 << " missing bus or address\n";
258 continue;
259 }
260 unsigned int configBus = std::visit(
261 VariantToUnsignedIntVisitor(), findBus->second);
262 unsigned int configAddress = std::visit(
263 VariantToUnsignedIntVisitor(), findAddress->second);
264
265 if (configBus == bus && configAddress == address)
266 {
267 sensorData = &(sensor.second);
268 break;
269 }
270 }
271 }
272 if (sensorData == nullptr)
273 {
274 std::cerr << "failed to find match for " << path.string()
275 << "\n";
James Feist95b079b2018-11-21 09:28:00 -0800276 continue;
277 }
James Feist95b079b2018-11-21 09:28:00 -0800278
James Feistde5e9702019-09-18 16:13:02 -0700279 auto findSensorName = baseConfiguration->second.find("Name");
Zhikui Ren347dd4e2019-12-12 13:39:50 -0800280
James Feistde5e9702019-09-18 16:13:02 -0700281 if (findSensorName == baseConfiguration->second.end())
James Feist95b079b2018-11-21 09:28:00 -0800282 {
James Feistde5e9702019-09-18 16:13:02 -0700283 std::cerr << "could not determine configuration name for "
284 << path.string() << "\n";
285 continue;
286 }
287 std::string sensorName =
288 std::get<std::string>(findSensorName->second);
Zhikui Ren347dd4e2019-12-12 13:39:50 -0800289
James Feistde5e9702019-09-18 16:13:02 -0700290 // on rescans, only update sensors we were signaled by
291 auto findSensor = tachSensors.find(sensorName);
292 if (!firstScan && findSensor != tachSensors.end())
293 {
294 bool found = false;
295 for (auto it = sensorsChanged->begin();
296 it != sensorsChanged->end(); it++)
297 {
298 if (boost::ends_with(*it, findSensor->second->name))
299 {
300 sensorsChanged->erase(it);
301 findSensor->second = nullptr;
302 found = true;
303 break;
304 }
305 }
306 if (!found)
307 {
308 continue;
309 }
310 }
311 std::vector<thresholds::Threshold> sensorThresholds;
312 if (!parseThresholdsFromConfig(*sensorData, sensorThresholds))
313 {
314 std::cerr << "error populating thresholds for "
315 << sensorName << "\n";
316 }
317
318 auto presenceConfig =
319 sensorData->find(baseType + std::string(".Presence"));
320
321 std::unique_ptr<PresenceSensor> presenceSensor(nullptr);
322
323 // presence sensors are optional
324 if (presenceConfig != sensorData->end())
325 {
James Feistde5e9702019-09-18 16:13:02 -0700326 auto findPolarity = presenceConfig->second.find("Polarity");
Zhikui Ren347dd4e2019-12-12 13:39:50 -0800327 auto findPinName = presenceConfig->second.find("PinName");
James Feistde5e9702019-09-18 16:13:02 -0700328
Zhikui Ren347dd4e2019-12-12 13:39:50 -0800329 if (findPinName == presenceConfig->second.end() ||
James Feistde5e9702019-09-18 16:13:02 -0700330 findPolarity == presenceConfig->second.end())
331 {
332 std::cerr << "Malformed Presence Configuration\n";
333 }
334 else
335 {
James Feistde5e9702019-09-18 16:13:02 -0700336 bool inverted = std::get<std::string>(
337 findPolarity->second) == "Low";
Zhikui Ren347dd4e2019-12-12 13:39:50 -0800338 if (auto pinName =
339 std::get_if<std::string>(&findPinName->second))
340 {
341 presenceSensor = std::make_unique<PresenceSensor>(
342 *pinName, inverted, io, sensorName);
343 }
344 else
345 {
346 std::cerr
347 << "Malformed Presence pinName for sensor "
348 << sensorName << " \n";
349 }
James Feistde5e9702019-09-18 16:13:02 -0700350 }
351 }
352 std::optional<RedundancySensor>* redundancy = nullptr;
353 if (fanType == FanTypes::aspeed)
354 {
355 redundancy = &systemRedundancy;
356 }
357
Josh Lehanf920e092020-08-07 00:12:54 -0700358 PowerState powerState = PowerState::on;
359 auto findPower = baseConfiguration->second.find("PowerState");
360 if (findPower != baseConfiguration->second.end())
361 {
362 auto ptrPower =
363 std::get_if<std::string>(&(findPower->second));
364 if (ptrPower)
365 {
366 setReadState(*ptrPower, powerState);
367 }
368 }
369
James Feistde5e9702019-09-18 16:13:02 -0700370 constexpr double defaultMaxReading = 25000;
371 constexpr double defaultMinReading = 0;
372 auto limits =
373 std::make_pair(defaultMinReading, defaultMaxReading);
374
James Feist49a8ccd2020-09-16 16:09:52 -0700375 auto connector =
376 sensorData->find(baseType + std::string(".Connector"));
377
378 std::optional<std::string> led;
Yong Zhao77b3add2021-01-09 04:25:18 +0000379 std::string pwmName;
Zhikui Rend05867c2021-02-26 16:10:34 -0800380 fs::path pwmPath;
James Feist49a8ccd2020-09-16 16:09:52 -0700381
Jie Yang3291b9c2021-07-29 14:46:51 -0700382 // The Mutable parameter is optional, defaulting to false
383 bool isValueMutable = false;
James Feist49a8ccd2020-09-16 16:09:52 -0700384 if (connector != sensorData->end())
385 {
386 auto findPwm = connector->second.find("Pwm");
387 if (findPwm != connector->second.end())
388 {
Jeff Linabf91de2020-12-23 10:55:42 +0800389 fs::path pwmEnableFile =
390 "pwm" + std::to_string(index + 1) + "_enable";
391 fs::path enablePath =
392 path.parent_path() / pwmEnableFile;
393 enablePwm(enablePath);
James Feist49a8ccd2020-09-16 16:09:52 -0700394 size_t pwm = std::visit(VariantToUnsignedIntVisitor(),
395 findPwm->second);
Zhikui Rend05867c2021-02-26 16:10:34 -0800396 pwmPath = directory / ("pwm" + std::to_string(pwm + 1));
James Feist49a8ccd2020-09-16 16:09:52 -0700397 /* use pwm name override if found in configuration else
398 * use default */
399 auto findOverride = connector->second.find("PwmName");
James Feist49a8ccd2020-09-16 16:09:52 -0700400 if (findOverride != connector->second.end())
401 {
402 pwmName = std::visit(VariantToStringVisitor(),
403 findOverride->second);
404 }
405 else
406 {
407 pwmName = "Pwm_" + std::to_string(pwm + 1);
408 }
Jie Yang3291b9c2021-07-29 14:46:51 -0700409
410 // Check PWM sensor mutability
411 auto findMutable = connector->second.find("Mutable");
412 if (findMutable != connector->second.end())
413 {
414 auto ptrMutable =
415 std::get_if<bool>(&(findMutable->second));
416 if (ptrMutable)
417 {
418 isValueMutable = *ptrMutable;
419 }
420 }
James Feist49a8ccd2020-09-16 16:09:52 -0700421 }
422 else
423 {
424 std::cerr << "Connector for " << sensorName
425 << " missing pwm!\n";
426 }
427
428 auto findLED = connector->second.find("LED");
429 if (findLED != connector->second.end())
430 {
431 auto ledName =
432 std::get_if<std::string>(&(findLED->second));
433 if (ledName == nullptr)
434 {
435 std::cerr << "Wrong format for LED of "
436 << sensorName << "\n";
437 }
438 else
439 {
440 led = *ledName;
441 }
442 }
443 }
444
James Feistde5e9702019-09-18 16:13:02 -0700445 findLimits(limits, baseConfiguration);
446 tachSensors[sensorName] = std::make_unique<TachSensor>(
447 path.string(), baseType, objectServer, dbusConnection,
448 std::move(presenceSensor), redundancy, io, sensorName,
Josh Lehanf920e092020-08-07 00:12:54 -0700449 std::move(sensorThresholds), *interfacePath, limits,
James Feist49a8ccd2020-09-16 16:09:52 -0700450 powerState, led);
Yong Zhao77b3add2021-01-09 04:25:18 +0000451
Zhikui Rend05867c2021-02-26 16:10:34 -0800452 if (!pwmPath.empty() && fs::exists(pwmPath) &&
453 !pwmSensors.count(pwmPath))
Yong Zhao77b3add2021-01-09 04:25:18 +0000454 {
455 pwmSensors[pwmPath] = std::make_unique<PwmSensor>(
456 pwmName, pwmPath, dbusConnection, objectServer,
Jie Yang3291b9c2021-07-29 14:46:51 -0700457 *interfacePath, "Fan", isValueMutable);
Yong Zhao77b3add2021-01-09 04:25:18 +0000458 }
James Feist95b079b2018-11-21 09:28:00 -0800459 }
Yong Zhao77b3add2021-01-09 04:25:18 +0000460
Kuiying Wangd5407412020-09-09 16:06:56 +0800461 createRedundancySensor(tachSensors, dbusConnection, objectServer);
Ed Tanous8a17c302021-09-02 15:07:11 -0700462 });
James Feistde5e9702019-09-18 16:13:02 -0700463 getter->getConfiguration(
James Feistf27a55c2020-08-04 14:27:30 -0700464 std::vector<std::string>{sensorTypes.begin(), sensorTypes.end()},
465 retries);
James Feist6714a252018-09-10 15:26:18 -0700466}
467
James Feistb6c0b912019-07-09 12:21:44 -0700468int main()
James Feist6714a252018-09-10 15:26:18 -0700469{
470 boost::asio::io_service io;
471 auto systemBus = std::make_shared<sdbusplus::asio::connection>(io);
472 systemBus->request_name("xyz.openbmc_project.FanSensor");
473 sdbusplus::asio::object_server objectServer(systemBus);
474 boost::container::flat_map<std::string, std::unique_ptr<TachSensor>>
475 tachSensors;
476 boost::container::flat_map<std::string, std::unique_ptr<PwmSensor>>
477 pwmSensors;
478 std::vector<std::unique_ptr<sdbusplus::bus::match::match>> matches;
James Feist5591cf082020-07-15 16:44:54 -0700479 auto sensorsChanged =
480 std::make_shared<boost::container::flat_set<std::string>>();
James Feist6714a252018-09-10 15:26:18 -0700481
482 io.post([&]() {
483 createSensors(io, objectServer, tachSensors, pwmSensors, systemBus,
484 nullptr);
485 });
486
487 boost::asio::deadline_timer filterTimer(io);
488 std::function<void(sdbusplus::message::message&)> eventHandler =
489 [&](sdbusplus::message::message& message) {
490 if (message.is_method_error())
491 {
492 std::cerr << "callback method error\n";
493 return;
494 }
495 sensorsChanged->insert(message.get_path());
496 // this implicitly cancels the timer
497 filterTimer.expires_from_now(boost::posix_time::seconds(1));
498
499 filterTimer.async_wait([&](const boost::system::error_code& ec) {
500 if (ec == boost::asio::error::operation_aborted)
501 {
502 /* we were canceled*/
503 return;
504 }
Ed Tanous8a57ec02020-10-09 12:46:52 -0700505 if (ec)
James Feist6714a252018-09-10 15:26:18 -0700506 {
507 std::cerr << "timer error\n";
508 return;
509 }
510 createSensors(io, objectServer, tachSensors, pwmSensors,
James Feistf27a55c2020-08-04 14:27:30 -0700511 systemBus, sensorsChanged, 5);
James Feist6714a252018-09-10 15:26:18 -0700512 });
513 };
514
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -0700515 for (const char* type : sensorTypes)
James Feist6714a252018-09-10 15:26:18 -0700516 {
517 auto match = std::make_unique<sdbusplus::bus::match::match>(
518 static_cast<sdbusplus::bus::bus&>(*systemBus),
519 "type='signal',member='PropertiesChanged',path_namespace='" +
Jae Hyun Yoo9ced0a32018-10-25 10:42:39 -0700520 std::string(inventoryPath) + "',arg0namespace='" + type + "'",
James Feist6714a252018-09-10 15:26:18 -0700521 eventHandler);
522 matches.emplace_back(std::move(match));
523 }
524
James Feistdc6c55f2018-10-31 12:53:20 -0700525 // redundancy sensor
526 std::function<void(sdbusplus::message::message&)> redundancyHandler =
527 [&tachSensors, &systemBus,
James Feistb6c0b912019-07-09 12:21:44 -0700528 &objectServer](sdbusplus::message::message&) {
James Feistdc6c55f2018-10-31 12:53:20 -0700529 createRedundancySensor(tachSensors, systemBus, objectServer);
530 };
531 auto match = std::make_unique<sdbusplus::bus::match::match>(
532 static_cast<sdbusplus::bus::bus&>(*systemBus),
533 "type='signal',member='PropertiesChanged',path_namespace='" +
534 std::string(inventoryPath) + "',arg0namespace='" +
535 redundancyConfiguration + "'",
James Feistb6c0b912019-07-09 12:21:44 -0700536 std::move(redundancyHandler));
James Feistdc6c55f2018-10-31 12:53:20 -0700537 matches.emplace_back(std::move(match));
538
Bruce Lee1263c3d2021-06-04 15:16:33 +0800539 setupManufacturingModeMatch(*systemBus);
James Feist6714a252018-09-10 15:26:18 -0700540 io.run();
Zhikui Ren8685b172021-06-29 15:16:52 -0700541 return 0;
James Feist6714a252018-09-10 15:26:18 -0700542}