| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2019 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 | */ |
| Andrew Jeffery | e73bd0a | 2023-01-25 10:39:57 +1030 | [diff] [blame] | 16 | |
| 17 | #include "MCUTempSensor.hpp" |
| 18 | |
| Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 19 | #include "SensorPaths.hpp" |
| 20 | #include "Thresholds.hpp" |
| Andrew Jeffery | e73bd0a | 2023-01-25 10:39:57 +1030 | [diff] [blame] | 21 | #include "Utils.hpp" |
| Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 22 | #include "sensor.hpp" |
| Andrew Jeffery | e73bd0a | 2023-01-25 10:39:57 +1030 | [diff] [blame] | 23 | |
| Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 24 | #include <fcntl.h> |
| 25 | #include <linux/i2c.h> |
| 26 | #include <sys/ioctl.h> |
| 27 | #include <unistd.h> |
| 28 | |
| 29 | #include <boost/asio/error.hpp> |
| 30 | #include <boost/asio/io_context.hpp> |
| 31 | #include <boost/asio/post.hpp> |
| 32 | #include <boost/asio/steady_timer.hpp> |
| Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 33 | #include <boost/container/flat_map.hpp> |
| George Liu | f2a2baa | 2025-02-20 17:32:51 +0800 | [diff] [blame] | 34 | #include <phosphor-logging/lg2.hpp> |
| James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 35 | #include <sdbusplus/asio/connection.hpp> |
| 36 | #include <sdbusplus/asio/object_server.hpp> |
| 37 | #include <sdbusplus/bus/match.hpp> |
| Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 38 | #include <sdbusplus/message.hpp> |
| James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 39 | |
| Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 40 | #include <array> |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 41 | #include <chrono> |
| Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 42 | #include <cstddef> |
| 43 | #include <cstdint> |
| Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 44 | #include <functional> |
| Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 45 | #include <memory> |
| Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 46 | #include <string> |
| Ed Tanous | eacbfdd | 2024-04-04 12:00:24 -0700 | [diff] [blame] | 47 | #include <utility> |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 48 | #include <vector> |
| 49 | |
| James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 50 | extern "C" |
| 51 | { |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 52 | #include <i2c/smbus.h> |
| 53 | #include <linux/i2c-dev.h> |
| 54 | } |
| 55 | |
| Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 56 | constexpr const char* sensorType = "MCUTempSensor"; |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 57 | static constexpr double mcuTempMaxReading = 0xFF; |
| 58 | static constexpr double mcuTempMinReading = 0; |
| 59 | |
| 60 | boost::container::flat_map<std::string, std::unique_ptr<MCUTempSensor>> sensors; |
| 61 | |
| Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 62 | MCUTempSensor::MCUTempSensor( |
| 63 | std::shared_ptr<sdbusplus::asio::connection>& conn, |
| 64 | boost::asio::io_context& io, const std::string& sensorName, |
| 65 | const std::string& sensorConfiguration, |
| 66 | sdbusplus::asio::object_server& objectServer, |
| 67 | std::vector<thresholds::Threshold>&& thresholdData, uint8_t busId, |
| 68 | uint8_t mcuAddress, uint8_t tempReg) : |
| Zhikui Ren | da98f09 | 2021-11-01 09:41:08 -0700 | [diff] [blame] | 69 | Sensor(escapeName(sensorName), std::move(thresholdData), |
| Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 70 | sensorConfiguration, "MCUTempSensor", false, false, |
| Zev Weiss | 34d7b97 | 2022-08-17 19:38:59 -0700 | [diff] [blame] | 71 | mcuTempMaxReading, mcuTempMinReading, conn), |
| Brad Bishop | fbb44ad | 2019-11-08 09:42:37 -0500 | [diff] [blame] | 72 | busId(busId), mcuAddress(mcuAddress), tempReg(tempReg), |
| James Feist | e333852 | 2020-09-15 15:40:30 -0700 | [diff] [blame] | 73 | objectServer(objectServer), waitTimer(io) |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 74 | { |
| 75 | sensorInterface = objectServer.add_interface( |
| 76 | "/xyz/openbmc_project/sensors/temperature/" + name, |
| 77 | "xyz.openbmc_project.Sensor.Value"); |
| 78 | |
| Jayashree Dhanapal | 5667808 | 2022-01-04 17:27:20 +0530 | [diff] [blame] | 79 | for (const auto& threshold : thresholds) |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 80 | { |
| Jayashree Dhanapal | 5667808 | 2022-01-04 17:27:20 +0530 | [diff] [blame] | 81 | std::string interface = thresholds::getInterface(threshold.level); |
| 82 | thresholdInterfaces[static_cast<size_t>(threshold.level)] = |
| 83 | objectServer.add_interface( |
| 84 | "/xyz/openbmc_project/sensors/temperature/" + name, interface); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 85 | } |
| 86 | association = objectServer.add_interface( |
| 87 | "/xyz/openbmc_project/sensors/temperature/" + name, |
| James Feist | 2adc95c | 2019-09-30 14:55:28 -0700 | [diff] [blame] | 88 | association::interface); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | MCUTempSensor::~MCUTempSensor() |
| 92 | { |
| 93 | waitTimer.cancel(); |
| Jayashree Dhanapal | 5667808 | 2022-01-04 17:27:20 +0530 | [diff] [blame] | 94 | for (const auto& iface : thresholdInterfaces) |
| 95 | { |
| 96 | objectServer.remove_interface(iface); |
| 97 | } |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 98 | objectServer.remove_interface(sensorInterface); |
| 99 | objectServer.remove_interface(association); |
| 100 | } |
| 101 | |
| Ed Tanous | 201a101 | 2024-04-03 18:07:28 -0700 | [diff] [blame] | 102 | void MCUTempSensor::init() |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 103 | { |
| Andrei Kartashev | 3928741 | 2022-02-04 16:04:47 +0300 | [diff] [blame] | 104 | setInitialProperties(sensor_paths::unitDegreesC); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 105 | read(); |
| 106 | } |
| 107 | |
| Ed Tanous | 201a101 | 2024-04-03 18:07:28 -0700 | [diff] [blame] | 108 | void MCUTempSensor::checkThresholds() |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 109 | { |
| 110 | thresholds::checkThresholds(this); |
| 111 | } |
| 112 | |
| Saitwal, Meghan | f1169f7 | 2023-04-23 05:14:14 +0000 | [diff] [blame] | 113 | int MCUTempSensor::getMCURegsInfoWord(uint8_t regs, int32_t* pu32data) const |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 114 | { |
| 115 | std::string i2cBus = "/dev/i2c-" + std::to_string(busId); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 116 | |
| Ed Tanous | 99c4409 | 2022-01-14 09:59:09 -0800 | [diff] [blame] | 117 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) |
| 118 | int fd = open(i2cBus.c_str(), O_RDWR); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 119 | if (fd < 0) |
| 120 | { |
| George Liu | f2a2baa | 2025-02-20 17:32:51 +0800 | [diff] [blame] | 121 | lg2::error("unable to open i2c device '{BUS}' err = '{ERR}'", "BUS", |
| 122 | i2cBus, "ERR", fd); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 123 | return -1; |
| 124 | } |
| 125 | |
| Ed Tanous | 99c4409 | 2022-01-14 09:59:09 -0800 | [diff] [blame] | 126 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 127 | if (ioctl(fd, I2C_SLAVE_FORCE, mcuAddress) < 0) |
| 128 | { |
| George Liu | f2a2baa | 2025-02-20 17:32:51 +0800 | [diff] [blame] | 129 | lg2::error("unable to set device address"); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 130 | close(fd); |
| 131 | return -1; |
| 132 | } |
| 133 | |
| 134 | unsigned long funcs = 0; |
| Ed Tanous | 99c4409 | 2022-01-14 09:59:09 -0800 | [diff] [blame] | 135 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 136 | if (ioctl(fd, I2C_FUNCS, &funcs) < 0) |
| 137 | { |
| George Liu | f2a2baa | 2025-02-20 17:32:51 +0800 | [diff] [blame] | 138 | lg2::error("not support I2C_FUNCS"); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 139 | close(fd); |
| 140 | return -1; |
| 141 | } |
| 142 | |
| Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 143 | if ((funcs & I2C_FUNC_SMBUS_READ_WORD_DATA) == 0U) |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 144 | { |
| George Liu | f2a2baa | 2025-02-20 17:32:51 +0800 | [diff] [blame] | 145 | lg2::error("not support I2C_FUNC_SMBUS_READ_WORD_DATA"); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 146 | close(fd); |
| 147 | return -1; |
| 148 | } |
| 149 | |
| Saitwal, Meghan | f1169f7 | 2023-04-23 05:14:14 +0000 | [diff] [blame] | 150 | *pu32data = i2c_smbus_read_word_data(fd, regs); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 151 | close(fd); |
| 152 | |
| Saitwal, Meghan | f1169f7 | 2023-04-23 05:14:14 +0000 | [diff] [blame] | 153 | if (*pu32data < 0) |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 154 | { |
| George Liu | f2a2baa | 2025-02-20 17:32:51 +0800 | [diff] [blame] | 155 | lg2::error(" read word data failed at '{REGS}'", "REGS", regs); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 156 | return -1; |
| 157 | } |
| 158 | |
| 159 | return 0; |
| 160 | } |
| 161 | |
| Ed Tanous | 201a101 | 2024-04-03 18:07:28 -0700 | [diff] [blame] | 162 | void MCUTempSensor::read() |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 163 | { |
| 164 | static constexpr size_t pollTime = 1; // in seconds |
| 165 | |
| Ed Tanous | 83db50c | 2023-03-01 10:20:24 -0800 | [diff] [blame] | 166 | waitTimer.expires_after(std::chrono::seconds(pollTime)); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 167 | waitTimer.async_wait([this](const boost::system::error_code& ec) { |
| 168 | if (ec == boost::asio::error::operation_aborted) |
| 169 | { |
| 170 | return; // we're being cancelled |
| 171 | } |
| 172 | // read timer error |
| Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 173 | if (ec) |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 174 | { |
| George Liu | f2a2baa | 2025-02-20 17:32:51 +0800 | [diff] [blame] | 175 | lg2::error("timer error"); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 176 | return; |
| 177 | } |
| Saitwal, Meghan | f1169f7 | 2023-04-23 05:14:14 +0000 | [diff] [blame] | 178 | int32_t temp = 0; |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 179 | int ret = getMCURegsInfoWord(tempReg, &temp); |
| 180 | if (ret >= 0) |
| 181 | { |
| 182 | double v = static_cast<double>(temp) / 1000; |
| Alexander Hansen | 89be614 | 2025-09-18 15:36:16 +0200 | [diff] [blame^] | 183 | lg2::debug("Value update to '{VALUE}' raw reading '{RAW}'", "VALUE", |
| 184 | v, "RAW", temp); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 185 | updateValue(v); |
| 186 | } |
| 187 | else |
| 188 | { |
| George Liu | f2a2baa | 2025-02-20 17:32:51 +0800 | [diff] [blame] | 189 | lg2::error("Invalid read getMCURegsInfoWord"); |
| James Feist | 961bf09 | 2020-07-01 16:38:12 -0700 | [diff] [blame] | 190 | incrementError(); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 191 | } |
| 192 | read(); |
| 193 | }); |
| 194 | } |
| 195 | |
| 196 | void createSensors( |
| Ed Tanous | 1f97863 | 2023-02-28 18:16:39 -0800 | [diff] [blame] | 197 | boost::asio::io_context& io, sdbusplus::asio::object_server& objectServer, |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 198 | boost::container::flat_map<std::string, std::unique_ptr<MCUTempSensor>>& |
| 199 | sensors, |
| 200 | std::shared_ptr<sdbusplus::asio::connection>& dbusConnection) |
| 201 | { |
| 202 | if (!dbusConnection) |
| 203 | { |
| George Liu | f2a2baa | 2025-02-20 17:32:51 +0800 | [diff] [blame] | 204 | lg2::error("Connection not created"); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 205 | return; |
| 206 | } |
| 207 | |
| 208 | dbusConnection->async_method_call( |
| 209 | [&io, &objectServer, &dbusConnection, &sensors]( |
| 210 | boost::system::error_code ec, const ManagedObjectType& resp) { |
| Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 211 | if (ec) |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 212 | { |
| George Liu | f2a2baa | 2025-02-20 17:32:51 +0800 | [diff] [blame] | 213 | lg2::error("Error contacting entity manager"); |
| Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 214 | return; |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 215 | } |
| Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 216 | for (const auto& [path, interfaces] : resp) |
| 217 | { |
| 218 | for (const auto& [intf, cfg] : interfaces) |
| 219 | { |
| 220 | if (intf != configInterfaceName(sensorType)) |
| 221 | { |
| 222 | continue; |
| 223 | } |
| 224 | std::string name = loadVariant<std::string>(cfg, "Name"); |
| 225 | |
| 226 | std::vector<thresholds::Threshold> sensorThresholds; |
| 227 | if (!parseThresholdsFromConfig(interfaces, |
| 228 | sensorThresholds)) |
| 229 | { |
| George Liu | f2a2baa | 2025-02-20 17:32:51 +0800 | [diff] [blame] | 230 | lg2::error("error populating thresholds for '{NAME}'", |
| 231 | "NAME", name); |
| Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | uint8_t busId = loadVariant<uint8_t>(cfg, "Bus"); |
| 235 | uint8_t mcuAddress = loadVariant<uint8_t>(cfg, "Address"); |
| 236 | uint8_t tempReg = loadVariant<uint8_t>(cfg, "Reg"); |
| 237 | |
| 238 | std::string sensorClass = |
| 239 | loadVariant<std::string>(cfg, "Class"); |
| 240 | |
| Alexander Hansen | 89be614 | 2025-09-18 15:36:16 +0200 | [diff] [blame^] | 241 | lg2::debug( |
| 242 | "Configuration parsed for '{INTERFACE}' with Name: {NAME}, Bus: {BUS}, " |
| 243 | "Address: {ADDRESS}, Reg: {REG}, Class: {CLASS}", |
| 244 | "INTERFACE", intf, "NAME", name, "BUS", busId, |
| 245 | "ADDRESS", mcuAddress, "REG", tempReg, "CLASS", |
| 246 | sensorClass); |
| Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 247 | |
| 248 | auto& sensor = sensors[name]; |
| 249 | |
| 250 | sensor = std::make_unique<MCUTempSensor>( |
| 251 | dbusConnection, io, name, path, objectServer, |
| 252 | std::move(sensorThresholds), busId, mcuAddress, |
| 253 | tempReg); |
| 254 | |
| 255 | sensor->init(); |
| 256 | } |
| 257 | } |
| 258 | }, |
| JeffLin | 2c5a1f2 | 2022-10-05 15:19:09 +0800 | [diff] [blame] | 259 | entityManagerName, "/xyz/openbmc_project/inventory", |
| 260 | "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 261 | } |
| 262 | |
| James Feist | b6c0b91 | 2019-07-09 12:21:44 -0700 | [diff] [blame] | 263 | int main() |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 264 | { |
| Ed Tanous | 1f97863 | 2023-02-28 18:16:39 -0800 | [diff] [blame] | 265 | boost::asio::io_context io; |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 266 | auto systemBus = std::make_shared<sdbusplus::asio::connection>(io); |
| Ed Tanous | 14ed5e9 | 2022-07-12 15:50:23 -0700 | [diff] [blame] | 267 | sdbusplus::asio::object_server objectServer(systemBus, true); |
| 268 | objectServer.add_manager("/xyz/openbmc_project/sensors"); |
| 269 | |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 270 | systemBus->request_name("xyz.openbmc_project.MCUTempSensor"); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 271 | |
| Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 272 | boost::asio::post(io, [&]() { |
| 273 | createSensors(io, objectServer, sensors, systemBus); |
| 274 | }); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 275 | |
| Ed Tanous | 9b4a20e | 2022-09-06 08:47:11 -0700 | [diff] [blame] | 276 | boost::asio::steady_timer configTimer(io); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 277 | |
| Patrick Williams | 92f8f51 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 278 | std::function<void(sdbusplus::message_t&)> eventHandler = |
| 279 | [&](sdbusplus::message_t&) { |
| Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 280 | configTimer.expires_after(std::chrono::seconds(1)); |
| 281 | // create a timer because normally multiple properties change |
| 282 | configTimer.async_wait([&](const boost::system::error_code& ec) { |
| 283 | if (ec == boost::asio::error::operation_aborted) |
| 284 | { |
| 285 | return; // we're being canceled |
| 286 | } |
| 287 | // config timer error |
| 288 | if (ec) |
| 289 | { |
| George Liu | f2a2baa | 2025-02-20 17:32:51 +0800 | [diff] [blame] | 290 | lg2::error("timer error"); |
| Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 291 | return; |
| 292 | } |
| 293 | createSensors(io, objectServer, sensors, systemBus); |
| 294 | if (sensors.empty()) |
| 295 | { |
| George Liu | f2a2baa | 2025-02-20 17:32:51 +0800 | [diff] [blame] | 296 | lg2::info("Configuration not detected"); |
| Patrick Williams | 2aaf717 | 2024-08-16 15:20:40 -0400 | [diff] [blame] | 297 | } |
| 298 | }); |
| 299 | }; |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 300 | |
| Zev Weiss | 214d971 | 2022-08-12 12:54:31 -0700 | [diff] [blame] | 301 | std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches = |
| 302 | setupPropertiesChangedMatches( |
| Zev Weiss | 054aad8 | 2022-08-18 01:37:34 -0700 | [diff] [blame] | 303 | *systemBus, std::to_array<const char*>({sensorType}), eventHandler); |
| Bruce Lee | 1263c3d | 2021-06-04 15:16:33 +0800 | [diff] [blame] | 304 | setupManufacturingModeMatch(*systemBus); |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 305 | io.run(); |
| Zhikui Ren | 8685b17 | 2021-06-29 15:16:52 -0700 | [diff] [blame] | 306 | return 0; |
| Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 307 | } |