| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| Brandon Kim | 9cf8562 | 2019-06-19 12:05:08 -0700 | [diff] [blame] | 3 | #include "config.h" |
| 4 | |
| Patrick Venture | 46470a3 | 2018-09-07 19:26:25 -0700 | [diff] [blame] | 5 | #include "sensorhandler.hpp" |
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 6 | |
| Vernon Mauery | e08fbff | 2019-04-03 09:19:34 -0700 | [diff] [blame] | 7 | #include <ipmid/api.hpp> |
| Vernon Mauery | 3325024 | 2019-03-12 16:49:26 -0700 | [diff] [blame] | 8 | #include <ipmid/types.hpp> |
| Vernon Mauery | 6a98fe7 | 2019-03-11 15:57:48 -0700 | [diff] [blame] | 9 | #include <ipmid/utils.hpp> |
| Tony Lee | c532425 | 2019-10-31 17:24:16 +0800 | [diff] [blame] | 10 | #include <phosphor-logging/elog-errors.hpp> |
| George Liu | 9b745a8 | 2024-07-19 09:09:36 +0800 | [diff] [blame] | 11 | #include <phosphor-logging/lg2.hpp> |
| William A. Kennington III | 4c00802 | 2018-10-12 17:18:14 -0700 | [diff] [blame] | 12 | #include <sdbusplus/message/types.hpp> |
| Alexander Hansen | 653aec0 | 2025-11-14 13:38:08 +0100 | [diff] [blame] | 13 | #include <xyz/openbmc_project/Sensor/Threshold/Critical/common.hpp> |
| 14 | #include <xyz/openbmc_project/Sensor/Threshold/Warning/common.hpp> |
| Alexander Hansen | f365c7f | 2025-11-14 12:08:34 +0100 | [diff] [blame] | 15 | #include <xyz/openbmc_project/Sensor/Value/common.hpp> |
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 16 | |
| Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 17 | #include <cmath> |
| 18 | |
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 19 | #ifdef FEATURE_SENSORS_CACHE |
| Lei YU | a55e9ea | 2021-09-18 15:15:17 +0800 | [diff] [blame] | 20 | |
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 21 | extern ipmi::sensor::SensorCacheMap sensorCacheMap; |
| Lei YU | a55e9ea | 2021-09-18 15:15:17 +0800 | [diff] [blame] | 22 | |
| 23 | // The signal's message type is 0x04 from DBus spec: |
| 24 | // https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages |
| 25 | static constexpr auto msgTypeSignal = 0x04; |
| 26 | |
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 27 | #endif |
| 28 | |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 29 | namespace ipmi |
| 30 | { |
| 31 | namespace sensor |
| 32 | { |
| 33 | |
| 34 | using Assertion = uint16_t; |
| 35 | using Deassertion = uint16_t; |
| 36 | using AssertionSet = std::pair<Assertion, Deassertion>; |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 37 | using Service = std::string; |
| 38 | using Path = std::string; |
| 39 | using Interface = std::string; |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 40 | using ServicePath = std::pair<Path, Service>; |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 41 | using Interfaces = std::vector<Interface>; |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 42 | using MapperResponseType = std::map<Path, std::map<Service, Interfaces>>; |
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 43 | using PropertyMap = ipmi::PropertyMap; |
| 44 | |
| Alexander Hansen | f365c7f | 2025-11-14 12:08:34 +0100 | [diff] [blame] | 45 | using SensorValue = sdbusplus::common::xyz::openbmc_project::sensor::Value; |
| Alexander Hansen | 653aec0 | 2025-11-14 13:38:08 +0100 | [diff] [blame] | 46 | using SensorThresholdWarning = |
| 47 | sdbusplus::common::xyz::openbmc_project::sensor::threshold::Warning; |
| 48 | using SensorThresholdCritical = |
| 49 | sdbusplus::common::xyz::openbmc_project::sensor::threshold::Critical; |
| Alexander Hansen | f365c7f | 2025-11-14 12:08:34 +0100 | [diff] [blame] | 50 | |
| Tony Lee | c532425 | 2019-10-31 17:24:16 +0800 | [diff] [blame] | 51 | using namespace phosphor::logging; |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 52 | |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 53 | /** @brief Make assertion set from input data |
| 54 | * @param[in] cmdData - Input sensor data |
| 55 | * @return pair of assertion and deassertion set |
| 56 | */ |
| 57 | AssertionSet getAssertionSet(const SetSensorReadingReq& cmdData); |
| 58 | |
| 59 | /** @brief send the message to DBus |
| 60 | * @param[in] msg - message to send |
| 61 | * @return failure status in IPMI error code |
| 62 | */ |
| George Liu | 23c868c | 2025-07-04 09:31:35 +0800 | [diff] [blame] | 63 | ipmi::Cc updateToDbus(IpmiUpdateData& msg); |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 64 | |
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 65 | namespace get |
| 66 | { |
| 67 | |
| Tom Joseph | b0adbcd | 2018-01-24 11:51:29 +0530 | [diff] [blame] | 68 | /** @brief Populate sensor name from the D-Bus property associated with the |
| 69 | * sensor. In the example entry from the yaml, the name of the D-bus |
| 70 | * property "AttemptsLeft" is the sensor name. |
| 71 | * |
| 72 | * 0x07: |
| 73 | * sensorType: 195 |
| 74 | * path: /xyz/openbmc_project/state/host0 |
| 75 | * sensorReadingType: 0x6F |
| 76 | * serviceInterface: org.freedesktop.DBus.Properties |
| 77 | * readingType: readingAssertion |
| 78 | * sensorNamePattern: nameProperty |
| 79 | * interfaces: |
| 80 | * xyz.openbmc_project.Control.Boot.RebootAttempts: |
| 81 | * AttemptsLeft: |
| 82 | * Offsets: |
| 83 | * 0xFF: |
| 84 | * type: uint32_t |
| 85 | * |
| 86 | * |
| 87 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 88 | * |
| 89 | * @return On success return the sensor name for the sensor. |
| 90 | */ |
| 91 | inline SensorName nameProperty(const Info& sensorInfo) |
| 92 | { |
| 93 | return sensorInfo.propertyInterfaces.begin()->second.begin()->first; |
| 94 | } |
| 95 | |
| 96 | /** @brief Populate sensor name from the D-Bus object associated with the |
| 97 | * sensor. If the object path is /system/chassis/motherboard/dimm0 then |
| 98 | * the leaf dimm0 is considered as the sensor name. |
| 99 | * |
| 100 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 101 | * |
| 102 | * @return On success return the sensor name for the sensor. |
| 103 | */ |
| 104 | inline SensorName nameLeaf(const Info& sensorInfo) |
| 105 | { |
| 106 | return sensorInfo.sensorPath.substr( |
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 107 | sensorInfo.sensorPath.find_last_of('/') + 1, |
| 108 | sensorInfo.sensorPath.length()); |
| Tom Joseph | b0adbcd | 2018-01-24 11:51:29 +0530 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | /** @brief Populate sensor name from the D-Bus object associated with the |
| Lotus Xu | 2101a44 | 2020-12-24 16:01:56 +0800 | [diff] [blame] | 112 | * sensor and the property. |
| 113 | * If the object path is /xyz/openbmc_project/inventory/Fan0 and |
| 114 | * the property is Present, the leaf Fan0 and the Property is |
| 115 | * joined to Fan0_Present as the sensor name. |
| 116 | * |
| 117 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 118 | * |
| 119 | * @return On success return the sensor name for the sensor. |
| 120 | */ |
| 121 | inline SensorName nameLeafProperty(const Info& sensorInfo) |
| 122 | { |
| 123 | return nameLeaf(sensorInfo) + "_" + nameProperty(sensorInfo); |
| 124 | } |
| 125 | |
| 126 | /** @brief Populate sensor name from the D-Bus object associated with the |
| Tom Joseph | b0adbcd | 2018-01-24 11:51:29 +0530 | [diff] [blame] | 127 | * sensor. If the object path is /system/chassis/motherboard/cpu0/core0 |
| 128 | * then the sensor name is cpu0_core0. The leaf and the parent is put |
| 129 | * together to get the sensor name. |
| 130 | * |
| 131 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 132 | * |
| 133 | * @return On success return the sensor name for the sensor. |
| 134 | */ |
| 135 | SensorName nameParentLeaf(const Info& sensorInfo); |
| 136 | |
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 137 | /** |
| 138 | * @brief Helper function to map the dbus info to sensor's assertion status |
| 139 | * for the get sensor reading command. |
| 140 | * |
| 141 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 142 | * @param[in] path - Dbus object path. |
| 143 | * @param[in] interface - Dbus interface. |
| 144 | * |
| 145 | * @return Response for get sensor reading command. |
| 146 | */ |
| 147 | GetSensorResponse mapDbusToAssertion(const Info& sensorInfo, |
| 148 | const InstancePath& path, |
| 149 | const DbusInterface& interface); |
| 150 | |
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 151 | #ifndef FEATURE_SENSORS_CACHE |
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 152 | /** |
| 153 | * @brief Map the Dbus info to sensor's assertion status in the Get sensor |
| 154 | * reading command response. |
| 155 | * |
| 156 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 157 | * |
| 158 | * @return Response for get sensor reading command. |
| 159 | */ |
| 160 | GetSensorResponse assertion(const Info& sensorInfo); |
| 161 | |
| Tom Joseph | e4014fc | 2017-09-06 23:57:36 +0530 | [diff] [blame] | 162 | /** |
| 163 | * @brief Maps the Dbus info to the reading field in the Get sensor reading |
| 164 | * command response. |
| 165 | * |
| 166 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 167 | * |
| 168 | * @return Response for get sensor reading command. |
| 169 | */ |
| 170 | GetSensorResponse eventdata2(const Info& sensorInfo); |
| 171 | |
| Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 172 | /** |
| 173 | * @brief readingAssertion is a case where the entire assertion state field |
| 174 | * serves as the sensor value. |
| 175 | * |
| 176 | * @tparam T - type of the dbus property related to sensor. |
| 177 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 178 | * |
| 179 | * @return Response for get sensor reading command. |
| 180 | */ |
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 181 | template <typename T> |
| Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 182 | GetSensorResponse readingAssertion(const Info& sensorInfo) |
| 183 | { |
| Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 184 | sdbusplus::bus_t bus{ipmid_get_sd_bus_connection()}; |
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 185 | GetSensorResponse response{}; |
| Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 186 | |
| George Liu | e6b2be5 | 2025-08-19 13:57:43 +0800 | [diff] [blame] | 187 | enableScanning(response); |
| George Liu | 08d3add | 2024-11-18 15:22:43 +0800 | [diff] [blame] | 188 | try |
| 189 | { |
| 190 | auto service = ipmi::getService(bus, sensorInfo.sensorInterface, |
| 191 | sensorInfo.sensorPath); |
| 192 | auto propValue = ipmi::getDbusProperty( |
| 193 | bus, service, sensorInfo.sensorPath, |
| 194 | sensorInfo.propertyInterfaces.begin()->first, |
| 195 | sensorInfo.propertyInterfaces.begin()->second.begin()->first); |
| Jeremy Kerr | 3dc3558 | 2020-05-17 15:47:07 +0800 | [diff] [blame] | 196 | |
| George Liu | 08d3add | 2024-11-18 15:22:43 +0800 | [diff] [blame] | 197 | setAssertionBytes(static_cast<uint16_t>(std::get<T>(propValue)), |
| George Liu | e6b2be5 | 2025-08-19 13:57:43 +0800 | [diff] [blame] | 198 | response); |
| George Liu | 08d3add | 2024-11-18 15:22:43 +0800 | [diff] [blame] | 199 | } |
| 200 | catch (const std::exception& e) |
| 201 | { |
| 202 | lg2::error( |
| 203 | "Failed to call readingAssertion, path: {PATH}, interface: {INTERFACE}: {ERROR}", |
| 204 | "PATH", sensorInfo.sensorPath, "INTERFACE", |
| 205 | sensorInfo.sensorInterface, "ERROR", e); |
| 206 | } |
| Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 207 | |
| 208 | return response; |
| 209 | } |
| 210 | |
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 211 | /** @brief Map the Dbus info to the reading field in the Get sensor reading |
| 212 | * command response |
| 213 | * |
| 214 | * @tparam T - type of the dbus property related to sensor. |
| 215 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 216 | * |
| 217 | * @return Response for get sensor reading command. |
| 218 | */ |
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 219 | template <typename T> |
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 220 | GetSensorResponse readingData(const Info& sensorInfo) |
| 221 | { |
| Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 222 | sdbusplus::bus_t bus{ipmid_get_sd_bus_connection()}; |
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 223 | |
| Sui Chen | 4cc4255 | 2019-09-11 10:28:35 -0700 | [diff] [blame] | 224 | GetSensorResponse response{}; |
| 225 | |
| George Liu | e6b2be5 | 2025-08-19 13:57:43 +0800 | [diff] [blame] | 226 | enableScanning(response); |
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 227 | |
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 228 | auto service = ipmi::getService(bus, sensorInfo.sensorInterface, |
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 229 | sensorInfo.sensorPath); |
| 230 | |
| Brandon Kim | 9cf8562 | 2019-06-19 12:05:08 -0700 | [diff] [blame] | 231 | #ifdef UPDATE_FUNCTIONAL_ON_FAIL |
| 232 | // Check the OperationalStatus interface for functional property |
| Alexander Hansen | f365c7f | 2025-11-14 12:08:34 +0100 | [diff] [blame] | 233 | if (sensorInfo.propertyInterfaces.begin()->first == SensorValue::interface) |
| Brandon Kim | 9cf8562 | 2019-06-19 12:05:08 -0700 | [diff] [blame] | 234 | { |
| 235 | bool functional = true; |
| 236 | try |
| 237 | { |
| 238 | auto funcValue = ipmi::getDbusProperty( |
| 239 | bus, service, sensorInfo.sensorPath, |
| 240 | "xyz.openbmc_project.State.Decorator.OperationalStatus", |
| 241 | "Functional"); |
| 242 | functional = std::get<bool>(funcValue); |
| 243 | } |
| 244 | catch (...) |
| 245 | { |
| 246 | // No-op if Functional property could not be found since this |
| 247 | // check is only valid for Sensor.Value read for hwmonio |
| 248 | } |
| 249 | if (!functional) |
| 250 | { |
| 251 | throw SensorFunctionalError(); |
| 252 | } |
| 253 | } |
| 254 | #endif |
| 255 | |
| George Liu | 08d3add | 2024-11-18 15:22:43 +0800 | [diff] [blame] | 256 | double value{}; |
| 257 | try |
| 258 | { |
| 259 | auto propValue = ipmi::getDbusProperty( |
| 260 | bus, service, sensorInfo.sensorPath, |
| 261 | sensorInfo.propertyInterfaces.begin()->first, |
| 262 | sensorInfo.propertyInterfaces.begin()->second.begin()->first); |
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 263 | |
| George Liu | 08d3add | 2024-11-18 15:22:43 +0800 | [diff] [blame] | 264 | value = std::get<T>(propValue) * |
| 265 | std::pow(10, sensorInfo.scale - sensorInfo.exponentR); |
| 266 | } |
| 267 | catch (const std::exception& e) |
| 268 | { |
| 269 | lg2::error( |
| 270 | "Failed to call readingData, path: {PATH}, interface: {INTERFACE}: {ERROR}", |
| 271 | "PATH", sensorInfo.sensorPath, "INTERFACE", |
| 272 | sensorInfo.sensorInterface, "ERROR", e); |
| 273 | return response; |
| 274 | } |
| 275 | |
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 276 | int32_t rawData = |
| 277 | (value - sensorInfo.scaledOffset) / sensorInfo.coefficientM; |
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 278 | |
| Tony Lee | c532425 | 2019-10-31 17:24:16 +0800 | [diff] [blame] | 279 | constexpr uint8_t sensorUnitsSignedBits = 2 << 6; |
| 280 | constexpr uint8_t signedDataFormat = 0x80; |
| 281 | // if sensorUnits1 [7:6] = 10b, sensor is signed |
| Willy Tu | 9154caa | 2021-12-02 02:28:54 -0800 | [diff] [blame] | 282 | int32_t minClamp; |
| 283 | int32_t maxClamp; |
| Tony Lee | c532425 | 2019-10-31 17:24:16 +0800 | [diff] [blame] | 284 | if ((sensorInfo.sensorUnits1 & sensorUnitsSignedBits) == signedDataFormat) |
| 285 | { |
| Willy Tu | 9154caa | 2021-12-02 02:28:54 -0800 | [diff] [blame] | 286 | minClamp = std::numeric_limits<int8_t>::lowest(); |
| 287 | maxClamp = std::numeric_limits<int8_t>::max(); |
| Tony Lee | c532425 | 2019-10-31 17:24:16 +0800 | [diff] [blame] | 288 | } |
| 289 | else |
| 290 | { |
| Willy Tu | 9154caa | 2021-12-02 02:28:54 -0800 | [diff] [blame] | 291 | minClamp = std::numeric_limits<uint8_t>::lowest(); |
| 292 | maxClamp = std::numeric_limits<uint8_t>::max(); |
| Tony Lee | c532425 | 2019-10-31 17:24:16 +0800 | [diff] [blame] | 293 | } |
| Willy Tu | 9154caa | 2021-12-02 02:28:54 -0800 | [diff] [blame] | 294 | setReading(static_cast<uint8_t>(std::clamp(rawData, minClamp, maxClamp)), |
| George Liu | e6b2be5 | 2025-08-19 13:57:43 +0800 | [diff] [blame] | 295 | response); |
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 296 | |
| Konstantin Aladyshev | f93b29c | 2021-05-05 14:49:14 +0300 | [diff] [blame] | 297 | if (!std::isfinite(value)) |
| 298 | { |
| 299 | response.readingOrStateUnavailable = 1; |
| 300 | } |
| 301 | |
| Konstantin Aladyshev | 778f659 | 2021-11-02 11:28:25 +0300 | [diff] [blame] | 302 | bool critAlarmHigh; |
| 303 | try |
| 304 | { |
| 305 | critAlarmHigh = std::get<bool>(ipmi::getDbusProperty( |
| 306 | bus, service, sensorInfo.sensorPath, |
| Alexander Hansen | 653aec0 | 2025-11-14 13:38:08 +0100 | [diff] [blame] | 307 | SensorThresholdCritical::interface, |
| 308 | SensorThresholdCritical::property_names::critical_alarm_high)); |
| Konstantin Aladyshev | 778f659 | 2021-11-02 11:28:25 +0300 | [diff] [blame] | 309 | } |
| 310 | catch (const std::exception& e) |
| 311 | { |
| 312 | critAlarmHigh = false; |
| 313 | } |
| 314 | bool critAlarmLow; |
| 315 | try |
| 316 | { |
| 317 | critAlarmLow = std::get<bool>(ipmi::getDbusProperty( |
| 318 | bus, service, sensorInfo.sensorPath, |
| Alexander Hansen | 653aec0 | 2025-11-14 13:38:08 +0100 | [diff] [blame] | 319 | SensorThresholdCritical::interface, |
| 320 | SensorThresholdCritical::property_names::critical_alarm_low)); |
| Konstantin Aladyshev | 778f659 | 2021-11-02 11:28:25 +0300 | [diff] [blame] | 321 | } |
| 322 | catch (const std::exception& e) |
| 323 | { |
| 324 | critAlarmLow = false; |
| 325 | } |
| 326 | bool warningAlarmHigh; |
| 327 | try |
| 328 | { |
| 329 | warningAlarmHigh = std::get<bool>(ipmi::getDbusProperty( |
| 330 | bus, service, sensorInfo.sensorPath, |
| Alexander Hansen | 653aec0 | 2025-11-14 13:38:08 +0100 | [diff] [blame] | 331 | SensorThresholdWarning::interface, |
| 332 | SensorThresholdWarning::property_names::warning_alarm_high)); |
| Konstantin Aladyshev | 778f659 | 2021-11-02 11:28:25 +0300 | [diff] [blame] | 333 | } |
| 334 | catch (const std::exception& e) |
| 335 | { |
| 336 | warningAlarmHigh = false; |
| 337 | } |
| 338 | bool warningAlarmLow; |
| 339 | try |
| 340 | { |
| 341 | warningAlarmLow = std::get<bool>(ipmi::getDbusProperty( |
| 342 | bus, service, sensorInfo.sensorPath, |
| Alexander Hansen | 653aec0 | 2025-11-14 13:38:08 +0100 | [diff] [blame] | 343 | SensorThresholdWarning::interface, |
| 344 | SensorThresholdWarning::property_names::warning_alarm_low)); |
| Konstantin Aladyshev | 778f659 | 2021-11-02 11:28:25 +0300 | [diff] [blame] | 345 | } |
| 346 | catch (const std::exception& e) |
| 347 | { |
| 348 | warningAlarmLow = false; |
| 349 | } |
| 350 | response.thresholdLevelsStates = |
| YouPengWu | 19c962b | 2025-10-17 19:00:18 +0800 | [diff] [blame] | 351 | 0xC0 | (static_cast<uint8_t>(warningAlarmLow) << 0) | |
| 352 | (static_cast<uint8_t>(critAlarmLow) << 1) | |
| 353 | (static_cast<uint8_t>(warningAlarmHigh) << 3) | |
| 354 | (static_cast<uint8_t>(critAlarmHigh) << 4); |
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 355 | return response; |
| 356 | } |
| 357 | |
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 358 | #else |
| 359 | |
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 360 | /** |
| 361 | * @brief Map the Dbus info to sensor's assertion status in the Get sensor |
| 362 | * reading command response. |
| 363 | * |
| 364 | * @param[in] id - The sensor id |
| 365 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 366 | * @param[in] msg - Dbus message from match callback. |
| 367 | * |
| 368 | * @return Response for get sensor reading command. |
| 369 | */ |
| 370 | std::optional<GetSensorResponse> assertion(uint8_t id, const Info& sensorInfo, |
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 371 | const PropertyMap& properties); |
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 372 | |
| 373 | /** |
| 374 | * @brief Maps the Dbus info to the reading field in the Get sensor reading |
| 375 | * command response. |
| 376 | * |
| 377 | * @param[in] id - The sensor id |
| 378 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 379 | * @param[in] msg - Dbus message from match callback. |
| 380 | * |
| 381 | * @return Response for get sensor reading command. |
| 382 | */ |
| 383 | std::optional<GetSensorResponse> eventdata2(uint8_t id, const Info& sensorInfo, |
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 384 | const PropertyMap& properties); |
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 385 | |
| 386 | /** |
| 387 | * @brief readingAssertion is a case where the entire assertion state field |
| 388 | * serves as the sensor value. |
| 389 | * |
| 390 | * @tparam T - type of the dbus property related to sensor. |
| 391 | * @param[in] id - The sensor id |
| 392 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 393 | * @param[in] msg - Dbus message from match callback. |
| 394 | * |
| 395 | * @return Response for get sensor reading command. |
| 396 | */ |
| 397 | template <typename T> |
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 398 | std::optional<GetSensorResponse> readingAssertion( |
| 399 | uint8_t id, const Info& sensorInfo, const PropertyMap& properties) |
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 400 | { |
| Lei YU | 7d72034 | 2021-09-18 18:39:09 +0800 | [diff] [blame] | 401 | GetSensorResponse response{}; |
| George Liu | e6b2be5 | 2025-08-19 13:57:43 +0800 | [diff] [blame] | 402 | enableScanning(response); |
| Lei YU | 7d72034 | 2021-09-18 18:39:09 +0800 | [diff] [blame] | 403 | |
| Lei YU | 7d72034 | 2021-09-18 18:39:09 +0800 | [diff] [blame] | 404 | auto iter = properties.find( |
| 405 | sensorInfo.propertyInterfaces.begin()->second.begin()->first); |
| 406 | if (iter == properties.end()) |
| 407 | { |
| 408 | return {}; |
| 409 | } |
| 410 | |
| 411 | setAssertionBytes(static_cast<uint16_t>(std::get<T>(iter->second)), |
| George Liu | e6b2be5 | 2025-08-19 13:57:43 +0800 | [diff] [blame] | 412 | response); |
| Lei YU | 7d72034 | 2021-09-18 18:39:09 +0800 | [diff] [blame] | 413 | |
| 414 | if (!sensorCacheMap[id].has_value()) |
| 415 | { |
| 416 | sensorCacheMap[id] = SensorData{}; |
| 417 | } |
| 418 | sensorCacheMap[id]->response = response; |
| 419 | return response; |
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | /** @brief Get sensor reading from the dbus message from match |
| 423 | * |
| 424 | * @tparam T - type of the dbus property related to sensor. |
| 425 | * @param[in] id - The sensor id |
| 426 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 427 | * @param[in] msg - Dbus message from match callback. |
| 428 | * |
| 429 | * @return Response for get sensor reading command. |
| 430 | */ |
| 431 | template <typename T> |
| 432 | std::optional<GetSensorResponse> readingData(uint8_t id, const Info& sensorInfo, |
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 433 | const PropertyMap& properties) |
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 434 | { |
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 435 | auto iter = properties.find("Functional"); |
| 436 | if (iter != properties.end()) |
| Lei YU | a55e9ea | 2021-09-18 15:15:17 +0800 | [diff] [blame] | 437 | { |
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 438 | sensorCacheMap[id]->functional = std::get<bool>(iter->second); |
| Lei YU | a55e9ea | 2021-09-18 15:15:17 +0800 | [diff] [blame] | 439 | } |
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 440 | iter = properties.find("Available"); |
| 441 | if (iter != properties.end()) |
| 442 | { |
| 443 | sensorCacheMap[id]->available = std::get<bool>(iter->second); |
| 444 | } |
| 445 | #ifdef UPDATE_FUNCTIONAL_ON_FAIL |
| 446 | if (sensorCacheMap[id]) |
| 447 | { |
| 448 | if (!sensorCacheMap[id]->functional) |
| 449 | { |
| 450 | throw SensorFunctionalError(); |
| 451 | } |
| 452 | } |
| 453 | #endif |
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 454 | |
| 455 | GetSensorResponse response{}; |
| 456 | |
| George Liu | e6b2be5 | 2025-08-19 13:57:43 +0800 | [diff] [blame] | 457 | enableScanning(response); |
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 458 | |
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 459 | iter = properties.find( |
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 460 | sensorInfo.propertyInterfaces.begin()->second.begin()->first); |
| 461 | if (iter == properties.end()) |
| 462 | { |
| 463 | return {}; |
| 464 | } |
| 465 | |
| 466 | double value = std::get<T>(iter->second) * |
| 467 | std::pow(10, sensorInfo.scale - sensorInfo.exponentR); |
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 468 | int32_t rawData = |
| 469 | (value - sensorInfo.scaledOffset) / sensorInfo.coefficientM; |
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 470 | |
| 471 | constexpr uint8_t sensorUnitsSignedBits = 2 << 6; |
| 472 | constexpr uint8_t signedDataFormat = 0x80; |
| 473 | // if sensorUnits1 [7:6] = 10b, sensor is signed |
| 474 | if ((sensorInfo.sensorUnits1 & sensorUnitsSignedBits) == signedDataFormat) |
| 475 | { |
| 476 | if (rawData > std::numeric_limits<int8_t>::max() || |
| 477 | rawData < std::numeric_limits<int8_t>::lowest()) |
| 478 | { |
| George Liu | 9b745a8 | 2024-07-19 09:09:36 +0800 | [diff] [blame] | 479 | lg2::error("Value out of range"); |
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 480 | throw std::out_of_range("Value out of range"); |
| 481 | } |
| George Liu | e6b2be5 | 2025-08-19 13:57:43 +0800 | [diff] [blame] | 482 | setReading(static_cast<int8_t>(rawData), response); |
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 483 | } |
| 484 | else |
| 485 | { |
| 486 | if (rawData > std::numeric_limits<uint8_t>::max() || |
| 487 | rawData < std::numeric_limits<uint8_t>::lowest()) |
| 488 | { |
| George Liu | 9b745a8 | 2024-07-19 09:09:36 +0800 | [diff] [blame] | 489 | lg2::error("Value out of range"); |
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 490 | throw std::out_of_range("Value out of range"); |
| 491 | } |
| George Liu | e6b2be5 | 2025-08-19 13:57:43 +0800 | [diff] [blame] | 492 | setReading(static_cast<uint8_t>(rawData), response); |
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | if (!std::isfinite(value)) |
| 496 | { |
| 497 | response.readingOrStateUnavailable = 1; |
| 498 | } |
| 499 | |
| 500 | if (!sensorCacheMap[id].has_value()) |
| 501 | { |
| 502 | sensorCacheMap[id] = SensorData{}; |
| 503 | } |
| 504 | sensorCacheMap[id]->response = response; |
| 505 | |
| 506 | return response; |
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | #endif // FEATURE_SENSORS_CACHE |
| 510 | |
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 511 | } // namespace get |
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 512 | |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 513 | namespace set |
| 514 | { |
| 515 | |
| 516 | /** @brief Make a DBus message for a Dbus call |
| 517 | * @param[in] updateInterface - Interface name |
| 518 | * @param[in] sensorPath - Path of the sensor |
| 519 | * @param[in] command - command to be executed |
| 520 | * @param[in] sensorInterface - DBus interface of sensor |
| 521 | * @return a dbus message |
| 522 | */ |
| 523 | IpmiUpdateData makeDbusMsg(const std::string& updateInterface, |
| 524 | const std::string& sensorPath, |
| 525 | const std::string& command, |
| 526 | const std::string& sensorInterface); |
| 527 | |
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 528 | /** @brief Update d-bus based on assertion type sensor data |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 529 | * @param[in] cmdData - input sensor data |
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 530 | * @param[in] sensorInfo - sensor d-bus info |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 531 | * @return a IPMI error code |
| 532 | */ |
| George Liu | 23c868c | 2025-07-04 09:31:35 +0800 | [diff] [blame] | 533 | ipmi::Cc assertion(const SetSensorReadingReq& cmdData, const Info& sensorInfo); |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 534 | |
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 535 | /** @brief Update d-bus based on a reading assertion |
| 536 | * @tparam T - type of d-bus property mapping this sensor |
| 537 | * @param[in] cmdData - input sensor data |
| 538 | * @param[in] sensorInfo - sensor d-bus info |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 539 | * @return a IPMI error code |
| 540 | */ |
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 541 | template <typename T> |
| George Liu | 23c868c | 2025-07-04 09:31:35 +0800 | [diff] [blame] | 542 | ipmi::Cc readingAssertion(const SetSensorReadingReq& cmdData, |
| 543 | const Info& sensorInfo) |
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 544 | { |
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 545 | auto msg = |
| 546 | makeDbusMsg("org.freedesktop.DBus.Properties", sensorInfo.sensorPath, |
| 547 | "Set", sensorInfo.sensorInterface); |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 548 | |
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 549 | const auto& interface = sensorInfo.propertyInterfaces.begin(); |
| 550 | msg.append(interface->first); |
| 551 | for (const auto& property : interface->second) |
| 552 | { |
| 553 | msg.append(property.first); |
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 554 | std::variant<T> value = static_cast<T>( |
| 555 | (cmdData.assertOffset8_14 << 8) | cmdData.assertOffset0_7); |
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 556 | msg.append(value); |
| 557 | } |
| 558 | return updateToDbus(msg); |
| 559 | } |
| 560 | |
| Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 561 | /** @brief Update d-bus based on a discrete reading |
| 562 | * @param[in] cmdData - input sensor data |
| 563 | * @param[in] sensorInfo - sensor d-bus info |
| 564 | * @return an IPMI error code |
| 565 | */ |
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 566 | template <typename T> |
| George Liu | 23c868c | 2025-07-04 09:31:35 +0800 | [diff] [blame] | 567 | ipmi::Cc readingData(const SetSensorReadingReq& cmdData, const Info& sensorInfo) |
| Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 568 | { |
| Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 569 | T raw_value = (sensorInfo.coefficientM * cmdData.reading) + |
| 570 | sensorInfo.scaledOffset; |
| Tom Joseph | 2210215 | 2018-03-02 18:46:39 +0530 | [diff] [blame] | 571 | |
| Patrick Venture | 586d35b | 2018-09-07 19:56:18 -0700 | [diff] [blame] | 572 | raw_value *= std::pow(10, sensorInfo.exponentR - sensorInfo.scale); |
| Tom Joseph | 2210215 | 2018-03-02 18:46:39 +0530 | [diff] [blame] | 573 | |
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 574 | auto msg = |
| 575 | makeDbusMsg("org.freedesktop.DBus.Properties", sensorInfo.sensorPath, |
| 576 | "Set", sensorInfo.sensorInterface); |
| Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 577 | |
| 578 | const auto& interface = sensorInfo.propertyInterfaces.begin(); |
| 579 | msg.append(interface->first); |
| 580 | |
| Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 581 | for (const auto& property : interface->second) |
| 582 | { |
| 583 | msg.append(property.first); |
| Vernon Mauery | 16b8693 | 2019-05-01 08:36:11 -0700 | [diff] [blame] | 584 | std::variant<T> value = raw_value; |
| Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 585 | msg.append(value); |
| 586 | } |
| 587 | return updateToDbus(msg); |
| 588 | } |
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 589 | |
| 590 | /** @brief Update d-bus based on eventdata type sensor data |
| 591 | * @param[in] cmdData - input sensor data |
| 592 | * @param[in] sensorInfo - sensor d-bus info |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 593 | * @return a IPMI error code |
| 594 | */ |
| George Liu | 23c868c | 2025-07-04 09:31:35 +0800 | [diff] [blame] | 595 | ipmi::Cc eventdata(const SetSensorReadingReq& cmdData, const Info& sensorInfo, |
| 596 | uint8_t data); |
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 597 | |
| 598 | /** @brief Update d-bus based on eventdata1 type sensor data |
| 599 | * @param[in] cmdData - input sensor data |
| 600 | * @param[in] sensorInfo - sensor d-bus info |
| 601 | * @return a IPMI error code |
| 602 | */ |
| George Liu | 23c868c | 2025-07-04 09:31:35 +0800 | [diff] [blame] | 603 | inline ipmi::Cc eventdata1(const SetSensorReadingReq& cmdData, |
| 604 | const Info& sensorInfo) |
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 605 | { |
| 606 | return eventdata(cmdData, sensorInfo, cmdData.eventData1); |
| 607 | } |
| 608 | |
| 609 | /** @brief Update d-bus based on eventdata2 type sensor data |
| 610 | * @param[in] cmdData - input sensor data |
| 611 | * @param[in] sensorInfo - sensor d-bus info |
| 612 | * @return a IPMI error code |
| 613 | */ |
| George Liu | 23c868c | 2025-07-04 09:31:35 +0800 | [diff] [blame] | 614 | inline ipmi::Cc eventdata2(const SetSensorReadingReq& cmdData, |
| 615 | const Info& sensorInfo) |
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 616 | { |
| 617 | return eventdata(cmdData, sensorInfo, cmdData.eventData2); |
| 618 | } |
| 619 | |
| 620 | /** @brief Update d-bus based on eventdata3 type sensor data |
| 621 | * @param[in] cmdData - input sensor data |
| 622 | * @param[in] sensorInfo - sensor d-bus info |
| 623 | * @return a IPMI error code |
| 624 | */ |
| George Liu | 23c868c | 2025-07-04 09:31:35 +0800 | [diff] [blame] | 625 | inline ipmi::Cc eventdata3(const SetSensorReadingReq& cmdData, |
| 626 | const Info& sensorInfo) |
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 627 | { |
| 628 | return eventdata(cmdData, sensorInfo, cmdData.eventData3); |
| 629 | } |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 630 | |
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 631 | } // namespace set |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 632 | |
| 633 | namespace notify |
| 634 | { |
| 635 | |
| 636 | /** @brief Make a DBus message for a Dbus call |
| 637 | * @param[in] updateInterface - Interface name |
| 638 | * @param[in] sensorPath - Path of the sensor |
| 639 | * @param[in] command - command to be executed |
| 640 | * @param[in] sensorInterface - DBus interface of sensor |
| 641 | * @return a dbus message |
| 642 | */ |
| 643 | IpmiUpdateData makeDbusMsg(const std::string& updateInterface, |
| 644 | const std::string& sensorPath, |
| 645 | const std::string& command, |
| 646 | const std::string& sensorInterface); |
| 647 | |
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 648 | /** @brief Update d-bus based on assertion type sensor data |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 649 | * @param[in] interfaceMap - sensor interface |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 650 | * @param[in] cmdData - input sensor data |
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 651 | * @param[in] sensorInfo - sensor d-bus info |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 652 | * @return a IPMI error code |
| 653 | */ |
| George Liu | 23c868c | 2025-07-04 09:31:35 +0800 | [diff] [blame] | 654 | ipmi::Cc assertion(const SetSensorReadingReq& cmdData, const Info& sensorInfo); |
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 655 | |
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 656 | } // namespace notify |
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 657 | |
| 658 | namespace inventory |
| 659 | { |
| 660 | |
| 661 | namespace get |
| 662 | { |
| 663 | |
| Lei YU | ff8c9b4 | 2021-10-15 14:20:57 +0800 | [diff] [blame] | 664 | #ifndef FEATURE_SENSORS_CACHE |
| 665 | |
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 666 | /** |
| 667 | * @brief Map the Dbus info to sensor's assertion status in the Get sensor |
| 668 | * reading command response. |
| 669 | * |
| 670 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 671 | * |
| 672 | * @return Response for get sensor reading command. |
| 673 | */ |
| 674 | GetSensorResponse assertion(const Info& sensorInfo); |
| 675 | |
| Lei YU | ff8c9b4 | 2021-10-15 14:20:57 +0800 | [diff] [blame] | 676 | #else |
| 677 | |
| 678 | /** |
| 679 | * @brief Map the Dbus info to sensor's assertion status in the Get sensor |
| 680 | * reading command response. |
| 681 | * |
| 682 | * @param[in] id - The sensor id |
| 683 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 684 | * @param[in] msg - Dbus message from match callback. |
| 685 | * |
| 686 | * @return Response for get sensor reading command. |
| 687 | */ |
| 688 | std::optional<GetSensorResponse> assertion(uint8_t id, const Info& sensorInfo, |
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 689 | const PropertyMap& properties); |
| Lei YU | ff8c9b4 | 2021-10-15 14:20:57 +0800 | [diff] [blame] | 690 | |
| 691 | #endif |
| 692 | |
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 693 | } // namespace get |
| 694 | |
| 695 | } // namespace inventory |
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 696 | } // namespace sensor |
| 697 | } // namespace ipmi |