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 "PwmSensor.hpp" |
| 18 | #include "TachSensor.hpp" |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 19 | #include "Thresholds.hpp" |
Andrew Jeffery | e73bd0a | 2023-01-25 10:39:57 +1030 | [diff] [blame] | 20 | #include "Utils.hpp" |
| 21 | #include "VariantVisitors.hpp" |
| 22 | |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 23 | #include <boost/algorithm/string/replace.hpp> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 24 | #include <boost/asio/error.hpp> |
| 25 | #include <boost/asio/io_context.hpp> |
| 26 | #include <boost/asio/post.hpp> |
| 27 | #include <boost/asio/steady_timer.hpp> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 28 | #include <boost/container/flat_map.hpp> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 29 | #include <boost/container/flat_set.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 30 | #include <sdbusplus/asio/connection.hpp> |
| 31 | #include <sdbusplus/asio/object_server.hpp> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 32 | #include <sdbusplus/bus.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 33 | #include <sdbusplus/bus/match.hpp> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 34 | #include <sdbusplus/message.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 35 | |
| 36 | #include <array> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 37 | #include <chrono> |
| 38 | #include <cstddef> |
| 39 | #include <cstdint> |
James Feist | 24f02f2 | 2019-04-15 11:05:39 -0700 | [diff] [blame] | 40 | #include <filesystem> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 41 | #include <fstream> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 42 | #include <functional> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 43 | #include <ios> |
| 44 | #include <iostream> |
| 45 | #include <map> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 46 | #include <memory> |
| 47 | #include <optional> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 48 | #include <regex> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 49 | #include <string> |
Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 50 | #include <system_error> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 51 | #include <utility> |
| 52 | #include <variant> |
| 53 | #include <vector> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 54 | |
James Feist | cf3bce6 | 2019-01-08 10:07:19 -0800 | [diff] [blame] | 55 | namespace fs = std::filesystem; |
James Feist | 3eb8262 | 2019-02-08 13:10:22 -0800 | [diff] [blame] | 56 | |
Yong Zhao | a3e8f2a | 2021-01-09 02:22:43 +0000 | [diff] [blame] | 57 | // The following two structures need to be consistent |
Chris Sides | c361e22 | 2023-04-05 15:18:20 -0500 | [diff] [blame] | 58 | static auto sensorTypes{std::to_array<const char*>( |
| 59 | {"AspeedFan", "I2CFan", "NuvotonFan", "HPEFan"})}; |
Yong Zhao | a3e8f2a | 2021-01-09 02:22:43 +0000 | [diff] [blame] | 60 | |
| 61 | enum FanTypes |
| 62 | { |
| 63 | aspeed = 0, |
| 64 | i2c, |
| 65 | nuvoton, |
Chris Sides | c361e22 | 2023-04-05 15:18:20 -0500 | [diff] [blame] | 66 | hpe, |
Yong Zhao | a3e8f2a | 2021-01-09 02:22:43 +0000 | [diff] [blame] | 67 | max, |
| 68 | }; |
| 69 | |
| 70 | static_assert(std::tuple_size<decltype(sensorTypes)>::value == FanTypes::max, |
| 71 | "sensorTypes element number is not equal to FanTypes number"); |
| 72 | |
James Feist | dc6c55f | 2018-10-31 12:53:20 -0700 | [diff] [blame] | 73 | constexpr const char* redundancyConfiguration = |
| 74 | "xyz.openbmc_project.Configuration.FanRedundancy"; |
Jae Hyun Yoo | 9ced0a3 | 2018-10-25 10:42:39 -0700 | [diff] [blame] | 75 | static std::regex inputRegex(R"(fan(\d+)_input)"); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 76 | |
James Feist | dc6c55f | 2018-10-31 12:53:20 -0700 | [diff] [blame] | 77 | // todo: power supply fan redundancy |
James Feist | 7b18b1e | 2019-05-14 13:42:09 -0700 | [diff] [blame] | 78 | std::optional<RedundancySensor> systemRedundancy; |
James Feist | 95b079b | 2018-11-21 09:28:00 -0800 | [diff] [blame] | 79 | |
Chris Sides | 3d5260d | 2023-04-10 15:45:00 -0500 | [diff] [blame] | 80 | static const std::map<std::string, FanTypes> compatibleFanTypes = { |
| 81 | {"aspeed,ast2400-pwm-tacho", FanTypes::aspeed}, |
| 82 | {"aspeed,ast2500-pwm-tacho", FanTypes::aspeed}, |
Potin Lai | 40c4d68 | 2023-05-19 17:19:03 +0800 | [diff] [blame] | 83 | {"aspeed,ast2600-pwm-tach", FanTypes::aspeed}, |
Chris Sides | c361e22 | 2023-04-05 15:18:20 -0500 | [diff] [blame] | 84 | {"nuvoton,npcm750-pwm-fan", FanTypes::nuvoton}, |
Brian Ma | d37e1db | 2023-05-08 13:36:53 +0800 | [diff] [blame] | 85 | {"nuvoton,npcm845-pwm-fan", FanTypes::nuvoton}, |
Chris Sides | c361e22 | 2023-04-05 15:18:20 -0500 | [diff] [blame] | 86 | {"hpe,gxp-fan-ctrl", FanTypes::hpe} |
Chris Sides | 3d5260d | 2023-04-10 15:45:00 -0500 | [diff] [blame] | 87 | // add compatible string here for new fan type |
| 88 | }; |
| 89 | |
James Feist | 95b079b | 2018-11-21 09:28:00 -0800 | [diff] [blame] | 90 | FanTypes getFanType(const fs::path& parentPath) |
| 91 | { |
Chris Sides | 9a472e8 | 2023-04-03 15:13:37 -0500 | [diff] [blame] | 92 | fs::path linkPath = parentPath / "of_node"; |
Zhikui Ren | 3996322 | 2023-05-04 17:06:50 -0700 | [diff] [blame] | 93 | if (!fs::exists(linkPath)) |
| 94 | { |
| 95 | return FanTypes::i2c; |
| 96 | } |
Chris Sides | 9a472e8 | 2023-04-03 15:13:37 -0500 | [diff] [blame] | 97 | |
Zhikui Ren | 3996322 | 2023-05-04 17:06:50 -0700 | [diff] [blame] | 98 | std::string canonical = fs::canonical(linkPath); |
Chris Sides | 9a472e8 | 2023-04-03 15:13:37 -0500 | [diff] [blame] | 99 | std::string compatiblePath = canonical + "/compatible"; |
| 100 | std::ifstream compatibleStream(compatiblePath); |
| 101 | |
Chris Sides | 3d5260d | 2023-04-10 15:45:00 -0500 | [diff] [blame] | 102 | if (!compatibleStream) |
James Feist | 95b079b | 2018-11-21 09:28:00 -0800 | [diff] [blame] | 103 | { |
Chris Sides | 9a472e8 | 2023-04-03 15:13:37 -0500 | [diff] [blame] | 104 | std::cerr << "Error opening " << compatiblePath << "\n"; |
Chris Sides | 3d5260d | 2023-04-10 15:45:00 -0500 | [diff] [blame] | 105 | return FanTypes::i2c; |
James Feist | 95b079b | 2018-11-21 09:28:00 -0800 | [diff] [blame] | 106 | } |
Chris Sides | 9a472e8 | 2023-04-03 15:13:37 -0500 | [diff] [blame] | 107 | |
| 108 | std::string compatibleString; |
Chris Sides | 3d5260d | 2023-04-10 15:45:00 -0500 | [diff] [blame] | 109 | while (std::getline(compatibleStream, compatibleString)) |
Peter Lundgren | 8843b62 | 2019-09-12 10:33:41 -0700 | [diff] [blame] | 110 | { |
Chris Sides | 9a472e8 | 2023-04-03 15:13:37 -0500 | [diff] [blame] | 111 | compatibleString.pop_back(); // trim EOL before comparisons |
| 112 | |
Chris Sides | 3d5260d | 2023-04-10 15:45:00 -0500 | [diff] [blame] | 113 | std::map<std::string, FanTypes>::const_iterator compatibleIterator = |
| 114 | compatibleFanTypes.find(compatibleString); |
| 115 | |
| 116 | if (compatibleIterator != compatibleFanTypes.end()) |
Chris Sides | 9a472e8 | 2023-04-03 15:13:37 -0500 | [diff] [blame] | 117 | { |
Chris Sides | 3d5260d | 2023-04-10 15:45:00 -0500 | [diff] [blame] | 118 | return compatibleIterator->second; |
Chris Sides | 9a472e8 | 2023-04-03 15:13:37 -0500 | [diff] [blame] | 119 | } |
Peter Lundgren | 8843b62 | 2019-09-12 10:33:41 -0700 | [diff] [blame] | 120 | } |
Chris Sides | 9a472e8 | 2023-04-03 15:13:37 -0500 | [diff] [blame] | 121 | |
James Feist | 95b079b | 2018-11-21 09:28:00 -0800 | [diff] [blame] | 122 | return FanTypes::i2c; |
| 123 | } |
Jeff Lin | abf91de | 2020-12-23 10:55:42 +0800 | [diff] [blame] | 124 | void enablePwm(const fs::path& filePath) |
| 125 | { |
| 126 | std::fstream enableFile(filePath, std::ios::in | std::ios::out); |
| 127 | if (!enableFile.good()) |
| 128 | { |
| 129 | std::cerr << "Error read/write " << filePath << "\n"; |
| 130 | return; |
| 131 | } |
James Feist | dc6c55f | 2018-10-31 12:53:20 -0700 | [diff] [blame] | 132 | |
Jeff Lin | abf91de | 2020-12-23 10:55:42 +0800 | [diff] [blame] | 133 | std::string regulateMode; |
| 134 | std::getline(enableFile, regulateMode); |
| 135 | if (regulateMode == "0") |
| 136 | { |
| 137 | enableFile << 1; |
| 138 | } |
| 139 | } |
Howard Chiu | ddf25d1 | 2021-12-02 15:14:44 +0800 | [diff] [blame] | 140 | bool findPwmfanPath(unsigned int configPwmfanIndex, fs::path& pwmPath) |
| 141 | { |
| 142 | /* Search PWM since pwm-fan had separated |
| 143 | * PWM from tach directory and 1 channel only*/ |
| 144 | std::vector<fs::path> pwmfanPaths; |
| 145 | std::string pwnfanDevName("pwm-fan"); |
| 146 | |
| 147 | pwnfanDevName += std::to_string(configPwmfanIndex); |
| 148 | |
| 149 | if (!findFiles(fs::path("/sys/class/hwmon"), R"(pwm\d+)", pwmfanPaths)) |
| 150 | { |
| 151 | std::cerr << "No PWMs are found!\n"; |
| 152 | return false; |
| 153 | } |
| 154 | for (const auto& path : pwmfanPaths) |
| 155 | { |
| 156 | std::error_code ec; |
| 157 | fs::path link = fs::read_symlink(path.parent_path() / "device", ec); |
| 158 | |
| 159 | if (ec) |
| 160 | { |
| 161 | std::cerr << "read_symlink() failed: " << ec.message() << " (" |
| 162 | << ec.value() << ")\n"; |
| 163 | continue; |
| 164 | } |
| 165 | |
| 166 | if (link.filename().string() == pwnfanDevName) |
| 167 | { |
| 168 | pwmPath = path; |
| 169 | return true; |
| 170 | } |
| 171 | } |
| 172 | return false; |
| 173 | } |
| 174 | bool findPwmPath(const fs::path& directory, unsigned int pwm, fs::path& pwmPath) |
| 175 | { |
| 176 | std::error_code ec; |
| 177 | |
| 178 | /* Assuming PWM file is appeared in the same directory as fanX_input */ |
| 179 | auto path = directory / ("pwm" + std::to_string(pwm + 1)); |
| 180 | bool exists = fs::exists(path, ec); |
| 181 | |
| 182 | if (ec || !exists) |
| 183 | { |
| 184 | /* PWM file not exist or error happened */ |
| 185 | if (ec) |
| 186 | { |
| 187 | std::cerr << "exists() failed: " << ec.message() << " (" |
| 188 | << ec.value() << ")\n"; |
| 189 | } |
| 190 | /* try search form pwm-fanX directory */ |
| 191 | return findPwmfanPath(pwm, pwmPath); |
| 192 | } |
| 193 | |
| 194 | pwmPath = path; |
| 195 | return true; |
| 196 | } |
Justin Ledford | 9c47bd7 | 2022-08-27 01:02:09 +0000 | [diff] [blame] | 197 | |
| 198 | // The argument to this function should be the fanN_input file that we want to |
| 199 | // enable. The function will locate the corresponding fanN_enable file if it |
| 200 | // exists. Note that some drivers don't provide this file if the sensors are |
| 201 | // always enabled. |
| 202 | void enableFanInput(const fs::path& fanInputPath) |
| 203 | { |
| 204 | std::error_code ec; |
| 205 | std::string path(fanInputPath.string()); |
| 206 | boost::replace_last(path, "input", "enable"); |
| 207 | |
| 208 | bool exists = fs::exists(path, ec); |
| 209 | if (ec || !exists) |
| 210 | { |
| 211 | return; |
| 212 | } |
| 213 | |
| 214 | std::fstream enableFile(path, std::ios::out); |
| 215 | if (!enableFile.good()) |
| 216 | { |
| 217 | return; |
| 218 | } |
| 219 | enableFile << 1; |
| 220 | } |
| 221 | |
Kuiying Wang | d540741 | 2020-09-09 16:06:56 +0800 | [diff] [blame] | 222 | void createRedundancySensor( |
Josh Lehan | 5170fe6 | 2022-08-03 13:17:41 -0700 | [diff] [blame] | 223 | const boost::container::flat_map<std::string, std::shared_ptr<TachSensor>>& |
Kuiying Wang | d540741 | 2020-09-09 16:06:56 +0800 | [diff] [blame] | 224 | sensors, |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 225 | const std::shared_ptr<sdbusplus::asio::connection>& conn, |
Kuiying Wang | d540741 | 2020-09-09 16:06:56 +0800 | [diff] [blame] | 226 | sdbusplus::asio::object_server& objectServer) |
| 227 | { |
Kuiying Wang | d540741 | 2020-09-09 16:06:56 +0800 | [diff] [blame] | 228 | conn->async_method_call( |
| 229 | [&objectServer, &sensors](boost::system::error_code& ec, |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 230 | const ManagedObjectType& managedObj) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 231 | if (ec) |
| 232 | { |
| 233 | std::cerr << "Error calling entity manager \n"; |
| 234 | return; |
| 235 | } |
Zev Weiss | 77636ec | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 236 | for (const auto& [path, interfaces] : managedObj) |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 237 | { |
Zev Weiss | 77636ec | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 238 | for (const auto& [intf, cfg] : interfaces) |
Kuiying Wang | d540741 | 2020-09-09 16:06:56 +0800 | [diff] [blame] | 239 | { |
Zev Weiss | 77636ec | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 240 | if (intf == redundancyConfiguration) |
Kuiying Wang | d540741 | 2020-09-09 16:06:56 +0800 | [diff] [blame] | 241 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 242 | // currently only support one |
Zev Weiss | 77636ec | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 243 | auto findCount = cfg.find("AllowedFailures"); |
| 244 | if (findCount == cfg.end()) |
Kuiying Wang | d540741 | 2020-09-09 16:06:56 +0800 | [diff] [blame] | 245 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 246 | std::cerr << "Malformed redundancy record \n"; |
Kuiying Wang | d540741 | 2020-09-09 16:06:56 +0800 | [diff] [blame] | 247 | return; |
| 248 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 249 | std::vector<std::string> sensorList; |
| 250 | |
Zev Weiss | 77636ec | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 251 | for (const auto& [name, sensor] : sensors) |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 252 | { |
| 253 | sensorList.push_back( |
| 254 | "/xyz/openbmc_project/sensors/fan_tach/" + |
Zev Weiss | 77636ec | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 255 | sensor->name); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 256 | } |
| 257 | systemRedundancy.reset(); |
Zev Weiss | 77636ec | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 258 | systemRedundancy.emplace( |
| 259 | RedundancySensor(std::get<uint64_t>(findCount->second), |
| 260 | sensorList, objectServer, path)); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 261 | |
| 262 | return; |
Kuiying Wang | d540741 | 2020-09-09 16:06:56 +0800 | [diff] [blame] | 263 | } |
| 264 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 265 | } |
Patrick Williams | 597e842 | 2023-10-20 11:19:01 -0500 | [diff] [blame] | 266 | }, |
Nan Zhou | 3e620af | 2022-09-20 22:28:31 +0000 | [diff] [blame] | 267 | "xyz.openbmc_project.EntityManager", "/xyz/openbmc_project/inventory", |
Kuiying Wang | d540741 | 2020-09-09 16:06:56 +0800 | [diff] [blame] | 268 | "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); |
| 269 | } |
| 270 | |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 271 | void createSensors( |
Ed Tanous | 1f97863 | 2023-02-28 18:16:39 -0800 | [diff] [blame] | 272 | boost::asio::io_context& io, sdbusplus::asio::object_server& objectServer, |
Josh Lehan | 5170fe6 | 2022-08-03 13:17:41 -0700 | [diff] [blame] | 273 | boost::container::flat_map<std::string, std::shared_ptr<TachSensor>>& |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 274 | tachSensors, |
| 275 | boost::container::flat_map<std::string, std::unique_ptr<PwmSensor>>& |
| 276 | pwmSensors, |
| 277 | std::shared_ptr<sdbusplus::asio::connection>& dbusConnection, |
James Feist | 5591cf08 | 2020-07-15 16:44:54 -0700 | [diff] [blame] | 278 | const std::shared_ptr<boost::container::flat_set<std::string>>& |
James Feist | f27a55c | 2020-08-04 14:27:30 -0700 | [diff] [blame] | 279 | sensorsChanged, |
| 280 | size_t retries = 0) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 281 | { |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 282 | auto getter = std::make_shared<GetSensorConfiguration>( |
| 283 | dbusConnection, |
Ed Tanous | 8a17c30 | 2021-09-02 15:07:11 -0700 | [diff] [blame] | 284 | [&io, &objectServer, &tachSensors, &pwmSensors, &dbusConnection, |
| 285 | sensorsChanged](const ManagedObjectType& sensorConfigurations) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 286 | bool firstScan = sensorsChanged == nullptr; |
| 287 | std::vector<fs::path> paths; |
| 288 | if (!findFiles(fs::path("/sys/class/hwmon"), R"(fan\d+_input)", paths)) |
| 289 | { |
| 290 | std::cerr << "No fan sensors in system\n"; |
| 291 | return; |
| 292 | } |
| 293 | |
| 294 | // iterate through all found fan sensors, and try to match them with |
| 295 | // configuration |
| 296 | for (const auto& path : paths) |
| 297 | { |
| 298 | std::smatch match; |
| 299 | std::string pathStr = path.string(); |
| 300 | |
| 301 | std::regex_search(pathStr, match, inputRegex); |
| 302 | std::string indexStr = *(match.begin() + 1); |
| 303 | |
| 304 | fs::path directory = path.parent_path(); |
| 305 | FanTypes fanType = getFanType(directory); |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 306 | std::string cfgIntf = configInterfaceName(sensorTypes[fanType]); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 307 | |
| 308 | // convert to 0 based |
| 309 | size_t index = std::stoul(indexStr) - 1; |
| 310 | |
| 311 | const char* baseType = nullptr; |
| 312 | const SensorData* sensorData = nullptr; |
| 313 | const std::string* interfacePath = nullptr; |
| 314 | const SensorBaseConfiguration* baseConfiguration = nullptr; |
Zev Weiss | 77636ec | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 315 | for (const auto& [path, cfgData] : sensorConfigurations) |
James Feist | 95b079b | 2018-11-21 09:28:00 -0800 | [diff] [blame] | 316 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 317 | // find the base of the configuration to see if indexes |
| 318 | // match |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 319 | auto sensorBaseFind = cfgData.find(cfgIntf); |
Zev Weiss | 77636ec | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 320 | if (sensorBaseFind == cfgData.end()) |
James Feist | 95b079b | 2018-11-21 09:28:00 -0800 | [diff] [blame] | 321 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 322 | continue; |
| 323 | } |
| 324 | |
| 325 | baseConfiguration = &(*sensorBaseFind); |
Zev Weiss | 77636ec | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 326 | interfacePath = &path.str; |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 327 | baseType = sensorTypes[fanType]; |
| 328 | |
| 329 | auto findIndex = baseConfiguration->second.find("Index"); |
| 330 | if (findIndex == baseConfiguration->second.end()) |
| 331 | { |
| 332 | std::cerr << baseConfiguration->first << " missing index\n"; |
| 333 | continue; |
| 334 | } |
| 335 | unsigned int configIndex = std::visit( |
| 336 | VariantToUnsignedIntVisitor(), findIndex->second); |
| 337 | if (configIndex != index) |
| 338 | { |
| 339 | continue; |
| 340 | } |
Chris Sides | c361e22 | 2023-04-05 15:18:20 -0500 | [diff] [blame] | 341 | if (fanType == FanTypes::aspeed || |
| 342 | fanType == FanTypes::nuvoton || fanType == FanTypes::hpe) |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 343 | { |
Chris Sides | c361e22 | 2023-04-05 15:18:20 -0500 | [diff] [blame] | 344 | // there will be only 1 aspeed or nuvoton or hpe sensor |
Chris Sides | 3d5260d | 2023-04-10 15:45:00 -0500 | [diff] [blame] | 345 | // object in sysfs, we found the fan |
Zev Weiss | 77636ec | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 346 | sensorData = &cfgData; |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 347 | break; |
| 348 | } |
| 349 | if (fanType == FanTypes::i2c) |
| 350 | { |
Akshit Shah | 03d333e | 2023-08-23 22:14:28 +0000 | [diff] [blame] | 351 | std::string deviceName = |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 352 | fs::read_symlink(directory / "device").filename(); |
| 353 | |
Akshit Shah | 03d333e | 2023-08-23 22:14:28 +0000 | [diff] [blame] | 354 | size_t bus = 0; |
| 355 | size_t addr = 0; |
| 356 | if (!getDeviceBusAddr(deviceName, bus, addr)) |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 357 | { |
Akshit Shah | 03d333e | 2023-08-23 22:14:28 +0000 | [diff] [blame] | 358 | continue; |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 359 | } |
Zhikui Ren | 347dd4e | 2019-12-12 13:39:50 -0800 | [diff] [blame] | 360 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 361 | auto findBus = baseConfiguration->second.find("Bus"); |
| 362 | auto findAddress = |
| 363 | baseConfiguration->second.find("Address"); |
| 364 | if (findBus == baseConfiguration->second.end() || |
| 365 | findAddress == baseConfiguration->second.end()) |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 366 | { |
| 367 | std::cerr << baseConfiguration->first |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 368 | << " missing bus or address\n"; |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 369 | continue; |
| 370 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 371 | unsigned int configBus = std::visit( |
| 372 | VariantToUnsignedIntVisitor(), findBus->second); |
| 373 | unsigned int configAddress = std::visit( |
| 374 | VariantToUnsignedIntVisitor(), findAddress->second); |
| 375 | |
Akshit Shah | 03d333e | 2023-08-23 22:14:28 +0000 | [diff] [blame] | 376 | if (configBus == bus && configAddress == addr) |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 377 | { |
Zev Weiss | 77636ec | 2022-08-12 18:21:01 -0700 | [diff] [blame] | 378 | sensorData = &cfgData; |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 379 | break; |
| 380 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 381 | } |
| 382 | } |
| 383 | if (sensorData == nullptr) |
| 384 | { |
| 385 | std::cerr << "failed to find match for " << path.string() |
| 386 | << "\n"; |
| 387 | continue; |
| 388 | } |
| 389 | |
| 390 | auto findSensorName = baseConfiguration->second.find("Name"); |
| 391 | |
| 392 | if (findSensorName == baseConfiguration->second.end()) |
| 393 | { |
| 394 | std::cerr << "could not determine configuration name for " |
| 395 | << path.string() << "\n"; |
| 396 | continue; |
| 397 | } |
| 398 | std::string sensorName = |
| 399 | std::get<std::string>(findSensorName->second); |
| 400 | |
| 401 | // on rescans, only update sensors we were signaled by |
| 402 | auto findSensor = tachSensors.find(sensorName); |
| 403 | if (!firstScan && findSensor != tachSensors.end()) |
| 404 | { |
| 405 | bool found = false; |
| 406 | for (auto it = sensorsChanged->begin(); |
| 407 | it != sensorsChanged->end(); it++) |
| 408 | { |
Zev Weiss | 6c106d6 | 2022-08-17 20:50:00 -0700 | [diff] [blame] | 409 | if (it->ends_with(findSensor->second->name)) |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 410 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 411 | sensorsChanged->erase(it); |
| 412 | findSensor->second = nullptr; |
| 413 | found = true; |
| 414 | break; |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 415 | } |
| 416 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 417 | if (!found) |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 418 | { |
James Feist | 95b079b | 2018-11-21 09:28:00 -0800 | [diff] [blame] | 419 | continue; |
| 420 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 421 | } |
| 422 | std::vector<thresholds::Threshold> sensorThresholds; |
| 423 | if (!parseThresholdsFromConfig(*sensorData, sensorThresholds)) |
| 424 | { |
| 425 | std::cerr << "error populating thresholds for " << sensorName |
| 426 | << "\n"; |
| 427 | } |
James Feist | 95b079b | 2018-11-21 09:28:00 -0800 | [diff] [blame] | 428 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 429 | auto presenceConfig = |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 430 | sensorData->find(cfgIntf + std::string(".Presence")); |
Zhikui Ren | 347dd4e | 2019-12-12 13:39:50 -0800 | [diff] [blame] | 431 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 432 | std::unique_ptr<PresenceSensor> presenceSensor(nullptr); |
| 433 | |
| 434 | // presence sensors are optional |
| 435 | if (presenceConfig != sensorData->end()) |
| 436 | { |
| 437 | auto findPolarity = presenceConfig->second.find("Polarity"); |
| 438 | auto findPinName = presenceConfig->second.find("PinName"); |
| 439 | |
| 440 | if (findPinName == presenceConfig->second.end() || |
| 441 | findPolarity == presenceConfig->second.end()) |
James Feist | 95b079b | 2018-11-21 09:28:00 -0800 | [diff] [blame] | 442 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 443 | std::cerr << "Malformed Presence Configuration\n"; |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 444 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 445 | else |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 446 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 447 | bool inverted = |
| 448 | std::get<std::string>(findPolarity->second) == "Low"; |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 449 | if (const auto* pinName = |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 450 | std::get_if<std::string>(&findPinName->second)) |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 451 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 452 | presenceSensor = std::make_unique<PresenceSensor>( |
| 453 | *pinName, inverted, io, sensorName); |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 454 | } |
| 455 | else |
| 456 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 457 | std::cerr << "Malformed Presence pinName for sensor " |
| 458 | << sensorName << " \n"; |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 459 | } |
| 460 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 461 | } |
| 462 | std::optional<RedundancySensor>* redundancy = nullptr; |
| 463 | if (fanType == FanTypes::aspeed) |
| 464 | { |
| 465 | redundancy = &systemRedundancy; |
| 466 | } |
| 467 | |
Zev Weiss | a4d2768 | 2022-07-19 15:30:36 -0700 | [diff] [blame] | 468 | PowerState powerState = getPowerState(baseConfiguration->second); |
Yong Zhao | 77b3add | 2021-01-09 04:25:18 +0000 | [diff] [blame] | 469 | |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 470 | constexpr double defaultMaxReading = 25000; |
| 471 | constexpr double defaultMinReading = 0; |
| 472 | std::pair<double, double> limits = |
| 473 | std::make_pair(defaultMinReading, defaultMaxReading); |
| 474 | |
| 475 | auto connector = |
Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 476 | sensorData->find(cfgIntf + std::string(".Connector")); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 477 | |
| 478 | std::optional<std::string> led; |
| 479 | std::string pwmName; |
| 480 | fs::path pwmPath; |
| 481 | |
| 482 | // The Mutable parameter is optional, defaulting to false |
| 483 | bool isValueMutable = false; |
| 484 | if (connector != sensorData->end()) |
| 485 | { |
| 486 | auto findPwm = connector->second.find("Pwm"); |
| 487 | if (findPwm != connector->second.end()) |
| 488 | { |
| 489 | size_t pwm = std::visit(VariantToUnsignedIntVisitor(), |
| 490 | findPwm->second); |
| 491 | if (!findPwmPath(directory, pwm, pwmPath)) |
| 492 | { |
| 493 | std::cerr << "Connector for " << sensorName |
| 494 | << " no pwm channel found!\n"; |
| 495 | continue; |
| 496 | } |
| 497 | |
Patrick Williams | 779c96a | 2023-05-10 07:50:42 -0500 | [diff] [blame] | 498 | fs::path pwmEnableFile = "pwm" + std::to_string(pwm + 1) + |
| 499 | "_enable"; |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 500 | fs::path enablePath = pwmPath.parent_path() / pwmEnableFile; |
| 501 | enablePwm(enablePath); |
| 502 | |
| 503 | /* use pwm name override if found in configuration else |
| 504 | * use default */ |
| 505 | auto findOverride = connector->second.find("PwmName"); |
| 506 | if (findOverride != connector->second.end()) |
| 507 | { |
| 508 | pwmName = std::visit(VariantToStringVisitor(), |
| 509 | findOverride->second); |
| 510 | } |
| 511 | else |
| 512 | { |
| 513 | pwmName = "Pwm_" + std::to_string(pwm + 1); |
| 514 | } |
| 515 | |
| 516 | // Check PWM sensor mutability |
| 517 | auto findMutable = connector->second.find("Mutable"); |
| 518 | if (findMutable != connector->second.end()) |
| 519 | { |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 520 | const auto* ptrMutable = |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 521 | std::get_if<bool>(&(findMutable->second)); |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 522 | if (ptrMutable != nullptr) |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 523 | { |
| 524 | isValueMutable = *ptrMutable; |
| 525 | } |
| 526 | } |
| 527 | } |
| 528 | else |
| 529 | { |
| 530 | std::cerr << "Connector for " << sensorName |
| 531 | << " missing pwm!\n"; |
| 532 | } |
| 533 | |
| 534 | auto findLED = connector->second.find("LED"); |
| 535 | if (findLED != connector->second.end()) |
| 536 | { |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 537 | const auto* ledName = |
| 538 | std::get_if<std::string>(&(findLED->second)); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 539 | if (ledName == nullptr) |
| 540 | { |
| 541 | std::cerr << "Wrong format for LED of " << sensorName |
| 542 | << "\n"; |
| 543 | } |
| 544 | else |
| 545 | { |
| 546 | led = *ledName; |
| 547 | } |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | findLimits(limits, baseConfiguration); |
Josh Lehan | 5170fe6 | 2022-08-03 13:17:41 -0700 | [diff] [blame] | 552 | |
Justin Ledford | 9c47bd7 | 2022-08-27 01:02:09 +0000 | [diff] [blame] | 553 | enableFanInput(path); |
| 554 | |
Josh Lehan | 5170fe6 | 2022-08-03 13:17:41 -0700 | [diff] [blame] | 555 | auto& tachSensor = tachSensors[sensorName]; |
| 556 | tachSensor = nullptr; |
| 557 | tachSensor = std::make_shared<TachSensor>( |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 558 | path.string(), baseType, objectServer, dbusConnection, |
| 559 | std::move(presenceSensor), redundancy, io, sensorName, |
| 560 | std::move(sensorThresholds), *interfacePath, limits, powerState, |
| 561 | led); |
Josh Lehan | 5170fe6 | 2022-08-03 13:17:41 -0700 | [diff] [blame] | 562 | tachSensor->setupRead(); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 563 | |
| 564 | if (!pwmPath.empty() && fs::exists(pwmPath) && |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 565 | (pwmSensors.count(pwmPath) == 0U)) |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 566 | { |
| 567 | pwmSensors[pwmPath] = std::make_unique<PwmSensor>( |
| 568 | pwmName, pwmPath, dbusConnection, objectServer, |
| 569 | *interfacePath, "Fan", isValueMutable); |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | createRedundancySensor(tachSensors, dbusConnection, objectServer); |
Patrick Williams | 597e842 | 2023-10-20 11:19:01 -0500 | [diff] [blame] | 574 | }); |
James Feist | de5e970 | 2019-09-18 16:13:02 -0700 | [diff] [blame] | 575 | getter->getConfiguration( |
James Feist | f27a55c | 2020-08-04 14:27:30 -0700 | [diff] [blame] | 576 | std::vector<std::string>{sensorTypes.begin(), sensorTypes.end()}, |
| 577 | retries); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 578 | } |
| 579 | |
James Feist | b6c0b91 | 2019-07-09 12:21:44 -0700 | [diff] [blame] | 580 | int main() |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 581 | { |
Ed Tanous | 1f97863 | 2023-02-28 18:16:39 -0800 | [diff] [blame] | 582 | boost::asio::io_context io; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 583 | auto systemBus = std::make_shared<sdbusplus::asio::connection>(io); |
Ed Tanous | 14ed5e9 | 2022-07-12 15:50:23 -0700 | [diff] [blame] | 584 | sdbusplus::asio::object_server objectServer(systemBus, true); |
| 585 | |
| 586 | objectServer.add_manager("/xyz/openbmc_project/sensors"); |
Ed Tanous | d906725 | 2022-10-22 15:35:52 -0700 | [diff] [blame] | 587 | objectServer.add_manager("/xyz/openbmc_project/control"); |
Lei YU | c2f83fe | 2022-12-02 14:49:47 +0800 | [diff] [blame] | 588 | objectServer.add_manager("/xyz/openbmc_project/inventory"); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 589 | systemBus->request_name("xyz.openbmc_project.FanSensor"); |
Josh Lehan | 5170fe6 | 2022-08-03 13:17:41 -0700 | [diff] [blame] | 590 | boost::container::flat_map<std::string, std::shared_ptr<TachSensor>> |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 591 | tachSensors; |
| 592 | boost::container::flat_map<std::string, std::unique_ptr<PwmSensor>> |
| 593 | pwmSensors; |
James Feist | 5591cf08 | 2020-07-15 16:44:54 -0700 | [diff] [blame] | 594 | auto sensorsChanged = |
| 595 | std::make_shared<boost::container::flat_set<std::string>>(); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 596 | |
Ed Tanous | 83db50c | 2023-03-01 10:20:24 -0800 | [diff] [blame] | 597 | boost::asio::post(io, [&]() { |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 598 | createSensors(io, objectServer, tachSensors, pwmSensors, systemBus, |
| 599 | nullptr); |
| 600 | }); |
| 601 | |
Ed Tanous | 9b4a20e | 2022-09-06 08:47:11 -0700 | [diff] [blame] | 602 | boost::asio::steady_timer filterTimer(io); |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 603 | std::function<void(sdbusplus::message_t&)> eventHandler = |
| 604 | [&](sdbusplus::message_t& message) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 605 | if (message.is_method_error()) |
| 606 | { |
| 607 | std::cerr << "callback method error\n"; |
| 608 | return; |
| 609 | } |
| 610 | sensorsChanged->insert(message.get_path()); |
| 611 | // this implicitly cancels the timer |
Ed Tanous | 83db50c | 2023-03-01 10:20:24 -0800 | [diff] [blame] | 612 | filterTimer.expires_after(std::chrono::seconds(1)); |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 613 | |
| 614 | filterTimer.async_wait([&](const boost::system::error_code& ec) { |
| 615 | if (ec == boost::asio::error::operation_aborted) |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 616 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 617 | /* we were canceled*/ |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 618 | return; |
| 619 | } |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 620 | if (ec) |
| 621 | { |
| 622 | std::cerr << "timer error\n"; |
| 623 | return; |
| 624 | } |
| 625 | createSensors(io, objectServer, tachSensors, pwmSensors, systemBus, |
| 626 | sensorsChanged, 5); |
| 627 | }); |
| 628 | }; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 629 | |
Zev Weiss | 214d971 | 2022-08-12 12:54:31 -0700 | [diff] [blame] | 630 | std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches = |
| 631 | setupPropertiesChangedMatches(*systemBus, sensorTypes, eventHandler); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 632 | |
James Feist | dc6c55f | 2018-10-31 12:53:20 -0700 | [diff] [blame] | 633 | // redundancy sensor |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 634 | std::function<void(sdbusplus::message_t&)> redundancyHandler = |
| 635 | [&tachSensors, &systemBus, &objectServer](sdbusplus::message_t&) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 636 | createRedundancySensor(tachSensors, systemBus, objectServer); |
| 637 | }; |
Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 638 | auto match = std::make_unique<sdbusplus::bus::match_t>( |
| 639 | static_cast<sdbusplus::bus_t&>(*systemBus), |
James Feist | dc6c55f | 2018-10-31 12:53:20 -0700 | [diff] [blame] | 640 | "type='signal',member='PropertiesChanged',path_namespace='" + |
| 641 | std::string(inventoryPath) + "',arg0namespace='" + |
| 642 | redundancyConfiguration + "'", |
James Feist | b6c0b91 | 2019-07-09 12:21:44 -0700 | [diff] [blame] | 643 | std::move(redundancyHandler)); |
James Feist | dc6c55f | 2018-10-31 12:53:20 -0700 | [diff] [blame] | 644 | matches.emplace_back(std::move(match)); |
| 645 | |
Bruce Lee | 1263c3d | 2021-06-04 15:16:33 +0800 | [diff] [blame] | 646 | setupManufacturingModeMatch(*systemBus); |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 647 | io.run(); |
Zhikui Ren | 8685b17 | 2021-06-29 15:16:52 -0700 | [diff] [blame] | 648 | return 0; |
James Feist | 6714a25 | 2018-09-10 15:26:18 -0700 | [diff] [blame] | 649 | } |