blob: 66395ea66b102be7eefbd9a80ba0711ea4d069f5 [file] [log] [blame]
Alexander Hansen46a755f2025-10-27 16:31:08 +01001// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright 2017 Google Inc
3
Pete O_o765a6d82025-07-23 21:44:14 -07004#include "config.h"
Jonico Eustaquioaf97d8e2024-01-02 14:35:07 -06005
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07006#include "dbuspassive.hpp"
7
Ed Tanousf8b6e552025-06-27 13:27:50 -07008#include "conf.hpp"
Patrick Ventureaadb30d2020-08-10 09:17:11 -07009#include "dbushelper_interface.hpp"
James Feist98b704e2019-06-03 16:24:53 -070010#include "dbuspassiveredundancy.hpp"
Patrick Ventureaadb30d2020-08-10 09:17:11 -070011#include "dbusutil.hpp"
James Zheng6df8bb52024-11-27 23:38:47 +000012#include "failsafeloggers/failsafe_logger_utility.hpp"
Ed Tanousf8b6e552025-06-27 13:27:50 -070013#include "interfaces.hpp"
James Feist0c8223b2019-05-08 15:33:33 -070014#include "util.hpp"
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070015
Ed Tanousf8b6e552025-06-27 13:27:50 -070016#include <systemd/sd-bus.h>
17
Patrick Venturea83a3ec2020-08-04 09:52:05 -070018#include <sdbusplus/bus.hpp>
Ed Tanousf8b6e552025-06-27 13:27:50 -070019#include <sdbusplus/message.hpp>
Alexander Hansend3e71ce2025-11-12 16:20:53 +010020#include <xyz/openbmc_project/Sensor/Threshold/Critical/common.hpp>
21#include <xyz/openbmc_project/Sensor/Threshold/Warning/common.hpp>
Alexander Hansendae4a3a2025-11-11 17:12:01 +010022#include <xyz/openbmc_project/Sensor/Value/client.hpp>
Alexander Hansen11a1edc2025-11-12 17:31:23 +010023#include <xyz/openbmc_project/State/Decorator/Availability/common.hpp>
24#include <xyz/openbmc_project/State/Decorator/OperationalStatus/common.hpp>
Patrick Venturea83a3ec2020-08-04 09:52:05 -070025
Patrick Venture863b9242018-03-08 08:29:23 -080026#include <chrono>
27#include <cmath>
Ed Tanousf8b6e552025-06-27 13:27:50 -070028#include <cstdint>
29#include <exception>
30#include <limits>
31#include <map>
Patrick Venture0ef1faf2018-06-13 12:50:53 -070032#include <memory>
Patrick Venture863b9242018-03-08 08:29:23 -080033#include <mutex>
Ed Tanousf8b6e552025-06-27 13:27:50 -070034#include <set>
Patrick Venture0ef1faf2018-06-13 12:50:53 -070035#include <string>
Ed Tanousf8b6e552025-06-27 13:27:50 -070036#include <utility>
James Feist1f802f52019-02-08 13:51:43 -080037#include <variant>
Patrick Venture863b9242018-03-08 08:29:23 -080038
James Zheng6df8bb52024-11-27 23:38:47 +000039#include "failsafeloggers/failsafe_logger.cpp"
40
Alexander Hansendae4a3a2025-11-11 17:12:01 +010041using SensorValue = sdbusplus::common::xyz::openbmc_project::sensor::Value;
Alexander Hansend3e71ce2025-11-12 16:20:53 +010042using SensorThresholdWarning =
43 sdbusplus::common::xyz::openbmc_project::sensor::threshold::Warning;
44using SensorThresholdCritical =
45 sdbusplus::common::xyz::openbmc_project::sensor::threshold::Critical;
Alexander Hansen11a1edc2025-11-12 17:31:23 +010046using StateDecoratorAvailability =
47 sdbusplus::common::xyz::openbmc_project::state::decorator::Availability;
48using StateDecoratorOperationalStatus = sdbusplus::common::xyz::
49 openbmc_project::state::decorator::OperationalStatus;
Alexander Hansendae4a3a2025-11-11 17:12:01 +010050
Patrick Venturea0764872020-08-08 07:48:43 -070051namespace pid_control
52{
53
Patrick Venture563a3562018-10-30 09:31:26 -070054std::unique_ptr<ReadInterface> DbusPassive::createDbusPassive(
Patrick Williamsb228bc32022-07-22 19:26:56 -050055 sdbusplus::bus_t& bus, const std::string& type, const std::string& id,
Patrick Venture8729eb92020-08-10 10:38:44 -070056 std::unique_ptr<DbusHelperInterface> helper, const conf::SensorConfig* info,
James Feist98b704e2019-06-03 16:24:53 -070057 const std::shared_ptr<DbusPassiveRedundancy>& redundancy)
Patrick Venture0ef1faf2018-06-13 12:50:53 -070058{
59 if (helper == nullptr)
60 {
61 return nullptr;
62 }
Patrick Venture7af157b2018-10-30 11:24:40 -070063 if (!validType(type))
Patrick Venture0ef1faf2018-06-13 12:50:53 -070064 {
65 return nullptr;
66 }
67
Patrick Venture863b9242018-03-08 08:29:23 -080068 /* Need to get the scale and initial value */
Patrick Venture863b9242018-03-08 08:29:23 -080069 /* service == busname */
Harvey.Wuf2efcbb2022-02-09 10:24:30 +080070 std::string path;
71 if (info->readPath.empty())
72 {
73 path = getSensorPath(type, id);
74 }
75 else
76 {
77 path = info->readPath;
78 }
Patrick Venture34ddc902018-10-30 11:05:17 -070079
Patrick Venture1df9e872020-10-08 15:35:01 -070080 SensorProperties settings;
Patrick Venturef8cb4642018-10-30 12:02:53 -070081 bool failed;
Eric Yang3bfece82025-08-26 10:20:01 +000082 bool objectMissing = false;
Eric Yang897f31c2025-05-16 20:40:56 +080083 std::string service;
Patrick Venture863b9242018-03-08 08:29:23 -080084
Patrick Venturef8cb4642018-10-30 12:02:53 -070085 try
86 {
Alexander Hansendae4a3a2025-11-11 17:12:01 +010087 service = helper->getService(SensorValue::interface, path);
Patrick Venturef8cb4642018-10-30 12:02:53 -070088 }
89 catch (const std::exception& e)
90 {
Chaul Lya552fe22024-11-15 10:20:28 +000091#ifndef HANDLE_MISSING_OBJECT_PATHS
Patrick Venturef8cb4642018-10-30 12:02:53 -070092 return nullptr;
Chaul Lya552fe22024-11-15 10:20:28 +000093#else
94 // CASE1: The sensor is not on DBus, but as it is not in the
95 // MissingIsAcceptable list, the sensor should be built with a failed
96 // state to send the zone to failsafe mode. Everything will recover if
97 // all important sensors are back to DBus. swampd will be informed
98 // through InterfacesAdded signals and the sensors will be built again.
99
Eric Yang897f31c2025-05-16 20:40:56 +0800100 // CASE2: The sensor is on D-Bus (getService succeeds) but getProperties
101 // fails (e.g., D-Bus error or property fetch failure). In this case,
102 // handle-missing-object-paths does not apply. The sensor build fails,
103 // and the control loop will keep restarting until getProperties
104 // succeeds.
Chaul Lya552fe22024-11-15 10:20:28 +0000105
Eric Yang897f31c2025-05-16 20:40:56 +0800106 // Only CASE1 may send the zone to failsafe mode if the sensor is not
107 // in MissingIsAcceptable. CASE2 results in continuous restart until
108 // recovery.
Chaul Lya552fe22024-11-15 10:20:28 +0000109
110 failed = true;
Eric Yang3bfece82025-08-26 10:20:01 +0000111 objectMissing = true;
Chaul Lya552fe22024-11-15 10:20:28 +0000112 settings.value = std::numeric_limits<double>::quiet_NaN();
113 settings.unit = getSensorUnit(type);
114 settings.available = false;
Eric Yang897f31c2025-05-16 20:40:56 +0800115 settings.unavailableAsFailed = true;
116 if (info->ignoreDbusMinMax)
117 {
118 settings.min = 0;
119 settings.max = 0;
120 }
Chaul Lya552fe22024-11-15 10:20:28 +0000121 std::cerr << "DbusPassive: Sensor " << path
122 << " is missing from D-Bus, build this sensor as failed\n";
Eric Yang897f31c2025-05-16 20:40:56 +0800123 return std::make_unique<DbusPassive>(
Eric Yang3bfece82025-08-26 10:20:01 +0000124 bus, type, id, std::move(helper), settings, failed, objectMissing,
125 path, redundancy);
Chaul Lya552fe22024-11-15 10:20:28 +0000126#endif
Patrick Venturef8cb4642018-10-30 12:02:53 -0700127 }
128
Eric Yang897f31c2025-05-16 20:40:56 +0800129 try
130 {
131 helper->getProperties(service, path, &settings);
132 failed = helper->thresholdsAsserted(service, path);
133 }
134 catch (const std::exception& e)
135 {
136 return nullptr;
137 }
138
Patrick Venture6b9f5992019-09-10 09:18:28 -0700139 /* if these values are zero, they're ignored. */
140 if (info->ignoreDbusMinMax)
141 {
142 settings.min = 0;
143 settings.max = 0;
144 }
145
Alex.Song8f73ad72021-10-07 00:18:27 +0800146 settings.unavailableAsFailed = info->unavailableAsFailed;
147
Eric Yang3bfece82025-08-26 10:20:01 +0000148 return std::make_unique<DbusPassive>(
149 bus, type, id, std::move(helper), settings, failed, objectMissing, path,
150 redundancy);
Patrick Venturef8cb4642018-10-30 12:02:53 -0700151}
152
James Feist98b704e2019-06-03 16:24:53 -0700153DbusPassive::DbusPassive(
Patrick Williamsb228bc32022-07-22 19:26:56 -0500154 sdbusplus::bus_t& bus, const std::string& type, const std::string& id,
Patrick Venture8729eb92020-08-10 10:38:44 -0700155 std::unique_ptr<DbusHelperInterface> helper,
Eric Yang3bfece82025-08-26 10:20:01 +0000156 const SensorProperties& settings, bool failed, bool objectMissing,
157 const std::string& path,
James Feist98b704e2019-06-03 16:24:53 -0700158 const std::shared_ptr<DbusPassiveRedundancy>& redundancy) :
Patrick Williamsbd63bca2024-08-16 15:21:10 -0400159 ReadInterface(), _signal(bus, getMatch(path), dbusHandleSignal, this),
Eric Yang3bfece82025-08-26 10:20:01 +0000160 _id(id), _helper(std::move(helper)), _failed(failed),
161 _objectMissing(objectMissing), path(path), redundancy(redundancy)
James Feist98b704e2019-06-03 16:24:53 -0700162
Patrick Venturef8cb4642018-10-30 12:02:53 -0700163{
Patrick Venture863b9242018-03-08 08:29:23 -0800164 _scale = settings.scale;
Josh Lehan3e2f7582020-09-20 22:06:03 -0700165 _min = settings.min * std::pow(10.0, _scale);
166 _max = settings.max * std::pow(10.0, _scale);
Alex.Song8f73ad72021-10-07 00:18:27 +0800167 _available = settings.available;
168 _unavailableAsFailed = settings.unavailableAsFailed;
Josh Lehan3e2f7582020-09-20 22:06:03 -0700169
170 // Cache this type knowledge, to avoid repeated string comparison
171 _typeMargin = (type == "margin");
Alex.Song8f73ad72021-10-07 00:18:27 +0800172 _typeFan = (type == "fan");
Josh Lehan3e2f7582020-09-20 22:06:03 -0700173
174 // Force value to be stored, otherwise member would be uninitialized
175 updateValue(settings.value, true);
Patrick Venture863b9242018-03-08 08:29:23 -0800176}
177
178ReadReturn DbusPassive::read(void)
179{
180 std::lock_guard<std::mutex> guard(_lock);
181
Josh Lehanb3005752022-02-22 20:48:07 -0800182 ReadReturn r = {_value, _updated, _unscaled};
Patrick Venture863b9242018-03-08 08:29:23 -0800183
184 return r;
185}
186
Josh Lehanb3005752022-02-22 20:48:07 -0800187void DbusPassive::setValue(double value, double unscaled)
Patrick Venture863b9242018-03-08 08:29:23 -0800188{
189 std::lock_guard<std::mutex> guard(_lock);
190
191 _value = value;
Josh Lehanb3005752022-02-22 20:48:07 -0800192 _unscaled = unscaled;
Patrick Venture863b9242018-03-08 08:29:23 -0800193 _updated = std::chrono::high_resolution_clock::now();
194}
195
Josh Lehanb3005752022-02-22 20:48:07 -0800196void DbusPassive::setValue(double value)
197{
198 // First param is scaled, second param is unscaled, assume same here
199 setValue(value, value);
200}
201
James Feist36b7d8e2018-10-05 15:39:01 -0700202bool DbusPassive::getFailed(void) const
203{
James Feist98b704e2019-06-03 16:24:53 -0700204 if (redundancy)
205 {
206 const std::set<std::string>& failures = redundancy->getFailed();
207 if (failures.find(path) != failures.end())
208 {
James Zheng6df8bb52024-11-27 23:38:47 +0000209 outputFailsafeLogWithSensor(_id, true, _id,
210 "The sensor path is marked redundant.");
James Feist98b704e2019-06-03 16:24:53 -0700211 return true;
212 }
213 }
James Feist4b36f262020-07-07 16:56:41 -0700214
Alex.Song8f73ad72021-10-07 00:18:27 +0800215 /*
Eric Yang3bfece82025-08-26 10:20:01 +0000216 * If handle-missing-object-paths is enabled, and the expected D-Bus object
217 * path is not exported, this sensor is created to represent that condition.
218 * Indicate this sensor has failed so the zone enters failSafe mode.
219 */
220 if (_objectMissing)
221 {
222 outputFailsafeLogWithSensor(_id, true, _id,
223 "The sensor D-Bus object is missing.");
224 return true;
225 }
226
227 /*
Alex.Song8f73ad72021-10-07 00:18:27 +0800228 * Unavailable thermal sensors, who are not present or
229 * power-state-not-matching, should not trigger the failSafe mode. For
230 * example, when a system stays at a powered-off state, its CPU Temp
231 * sensors will be unavailable, these unavailable sensors should not be
232 * treated as failed and trigger failSafe.
233 * This is important for systems whose Fans are always on.
234 */
235 if (!_typeFan && !_available && !_unavailableAsFailed)
236 {
237 return false;
238 }
239
Josh Lehan3e2f7582020-09-20 22:06:03 -0700240 // If a reading has came in,
241 // but its value bad in some way (determined by sensor type),
242 // indicate this sensor has failed,
243 // until another value comes in that is no longer bad.
244 // This is different from the overall _failed flag,
245 // which is set and cleared by other causes.
246 if (_badReading)
247 {
James Zheng6df8bb52024-11-27 23:38:47 +0000248 outputFailsafeLogWithSensor(_id, true, _id,
249 "The sensor has bad readings.");
Josh Lehan3e2f7582020-09-20 22:06:03 -0700250 return true;
251 }
252
253 // If a reading has came in, and it is not a bad reading,
254 // but it indicates there is no more thermal margin left,
255 // that is bad, something is wrong with the PID loops,
256 // they are not cooling the system, enable failsafe mode also.
257 if (_marginHot)
258 {
James Zheng6df8bb52024-11-27 23:38:47 +0000259 outputFailsafeLogWithSensor(_id, true, _id,
260 "The sensor has no thermal margin left.");
Josh Lehan3e2f7582020-09-20 22:06:03 -0700261 return true;
262 }
263
James Zheng6df8bb52024-11-27 23:38:47 +0000264 if (_failed)
265 {
266 outputFailsafeLogWithSensor(
267 _id, true, _id, "The sensor has failed with a critical issue.");
268 return true;
269 }
270
271 if (!_available)
272 {
273 outputFailsafeLogWithSensor(_id, true, _id,
274 "The sensor is unavailable.");
275 return true;
276 }
277
278 if (!_functional)
279 {
280 outputFailsafeLogWithSensor(_id, true, _id,
281 "The sensor is not functional.");
282 return true;
283 }
284
285 outputFailsafeLogWithSensor(_id, false, _id, "The sensor has recovered.");
286
287 return false;
James Feist36b7d8e2018-10-05 15:39:01 -0700288}
289
Harvey Wua4270072024-05-29 16:11:13 +0800290std::string DbusPassive::getFailReason(void) const
291{
Eric Yang3bfece82025-08-26 10:20:01 +0000292 if (_objectMissing)
293 {
294 return "Sensor D-Bus object missing";
295 }
Harvey Wua4270072024-05-29 16:11:13 +0800296 if (_badReading)
297 {
298 return "Sensor reading bad";
299 }
300 if (_marginHot)
301 {
302 return "Margin hot";
303 }
304 if (_failed)
305 {
306 return "Sensor threshold asserted";
307 }
308 if (!_available)
309 {
310 return "Sensor unavailable";
311 }
312 if (!_functional)
313 {
314 return "Sensor not functional";
315 }
316 return "Unknown";
317}
318
James Feist36b7d8e2018-10-05 15:39:01 -0700319void DbusPassive::setFailed(bool value)
320{
321 _failed = value;
322}
323
James Feist4b36f262020-07-07 16:56:41 -0700324void DbusPassive::setFunctional(bool value)
325{
326 _functional = value;
327}
328
Alex.Song8f73ad72021-10-07 00:18:27 +0800329void DbusPassive::setAvailable(bool value)
330{
331 _available = value;
332}
333
Patrick Venture863b9242018-03-08 08:29:23 -0800334int64_t DbusPassive::getScale(void)
335{
336 return _scale;
337}
338
Patrick Venture563a3562018-10-30 09:31:26 -0700339std::string DbusPassive::getID(void)
Patrick Venture863b9242018-03-08 08:29:23 -0800340{
341 return _id;
342}
343
James Feist75eb7692019-02-25 12:50:02 -0800344double DbusPassive::getMax(void)
345{
346 return _max;
347}
348
349double DbusPassive::getMin(void)
350{
351 return _min;
352}
353
Josh Lehan3e2f7582020-09-20 22:06:03 -0700354void DbusPassive::updateValue(double value, bool force)
355{
356 _badReading = false;
357
358 // Do not let a NAN, or other floating-point oddity, be used to update
359 // the value, as that indicates the sensor has no valid reading.
360 if (!(std::isfinite(value)))
361 {
362 _badReading = true;
363
364 // Do not continue with a bad reading, unless caller forcing
365 if (!force)
366 {
367 return;
368 }
369 }
370
371 value *= std::pow(10.0, _scale);
372
373 auto unscaled = value;
374 scaleSensorReading(_min, _max, value);
375
376 if (_typeMargin)
377 {
378 _marginHot = false;
379
380 // Unlike an absolute temperature sensor,
381 // where 0 degrees C is a good reading,
382 // a value received of 0 (or negative) margin is worrisome,
383 // and should be flagged.
384 // Either it indicates margin not calculated properly,
385 // or somebody forgot to set the margin-zero setpoint,
386 // or the system is really overheating that much.
387 // This is a different condition from _failed
388 // and _badReading, so it merits its own flag.
389 // The sensor has not failed, the reading is good, but the zone
390 // still needs to know that it should go to failsafe mode.
391 if (unscaled <= 0.0)
392 {
393 _marginHot = true;
394 }
395 }
396
Josh Lehanb3005752022-02-22 20:48:07 -0800397 setValue(value, unscaled);
Josh Lehan3e2f7582020-09-20 22:06:03 -0700398}
399
Patrick Williamsb228bc32022-07-22 19:26:56 -0500400int handleSensorValue(sdbusplus::message_t& msg, DbusPassive* owner)
Patrick Venture863b9242018-03-08 08:29:23 -0800401{
Patrick Venture863b9242018-03-08 08:29:23 -0800402 std::string msgSensor;
James Feist1f802f52019-02-08 13:51:43 -0800403 std::map<std::string, std::variant<int64_t, double, bool>> msgData;
Patrick Ventured0c75662018-06-12 19:03:21 -0700404
405 msg.read(msgSensor, msgData);
Patrick Venture863b9242018-03-08 08:29:23 -0800406
Alexander Hansendae4a3a2025-11-11 17:12:01 +0100407 if (msgSensor == SensorValue::interface)
Patrick Venture863b9242018-03-08 08:29:23 -0800408 {
Alexander Hansendae4a3a2025-11-11 17:12:01 +0100409 auto valPropMap = msgData.find(SensorValue::property_names::value);
Patrick Venture863b9242018-03-08 08:29:23 -0800410 if (valPropMap != msgData.end())
411 {
Patrick Williamsbd63bca2024-08-16 15:21:10 -0400412 double value =
413 std::visit(VariantToDoubleVisitor(), valPropMap->second);
Patrick Venture863b9242018-03-08 08:29:23 -0800414
Josh Lehan3e2f7582020-09-20 22:06:03 -0700415 owner->updateValue(value, false);
Patrick Venture863b9242018-03-08 08:29:23 -0800416 }
417 }
Alexander Hansend3e71ce2025-11-12 16:20:53 +0100418 else if (msgSensor == SensorThresholdCritical::interface)
James Feist36b7d8e2018-10-05 15:39:01 -0700419 {
Alexander Hansend3e71ce2025-11-12 16:20:53 +0100420 auto criticalAlarmLow = msgData.find(
421 SensorThresholdCritical::property_names::critical_alarm_low);
422 auto criticalAlarmHigh = msgData.find(
423 SensorThresholdCritical::property_names::critical_alarm_high);
James Feist36b7d8e2018-10-05 15:39:01 -0700424 if (criticalAlarmHigh == msgData.end() &&
425 criticalAlarmLow == msgData.end())
426 {
427 return 0;
428 }
429
430 bool asserted = false;
431 if (criticalAlarmLow != msgData.end())
432 {
James Feist1f802f52019-02-08 13:51:43 -0800433 asserted = std::get<bool>(criticalAlarmLow->second);
James Feist36b7d8e2018-10-05 15:39:01 -0700434 }
435
436 // checking both as in theory you could de-assert one threshold and
437 // assert the other at the same moment
438 if (!asserted && criticalAlarmHigh != msgData.end())
439 {
James Feist1f802f52019-02-08 13:51:43 -0800440 asserted = std::get<bool>(criticalAlarmHigh->second);
James Feist36b7d8e2018-10-05 15:39:01 -0700441 }
442 owner->setFailed(asserted);
443 }
Jonico Eustaquioaf97d8e2024-01-02 14:35:07 -0600444#ifdef UNC_FAILSAFE
Alexander Hansend3e71ce2025-11-12 16:20:53 +0100445 else if (msgSensor == SensorThresholdWarning::interface)
Jonico Eustaquioaf97d8e2024-01-02 14:35:07 -0600446 {
Alexander Hansend3e71ce2025-11-12 16:20:53 +0100447 auto warningAlarmHigh = msgData.find(
448 SensorThresholdWarning::property_names::warning_alarm_high);
Jonico Eustaquioaf97d8e2024-01-02 14:35:07 -0600449 if (warningAlarmHigh == msgData.end())
450 {
451 return 0;
452 }
453
454 bool asserted = false;
455 if (warningAlarmHigh != msgData.end())
456 {
457 asserted = std::get<bool>(warningAlarmHigh->second);
458 }
459 owner->setFailed(asserted);
460 }
461#endif
Alexander Hansen11a1edc2025-11-12 17:31:23 +0100462 else if (msgSensor == StateDecoratorAvailability::interface)
Alex.Song8f73ad72021-10-07 00:18:27 +0800463 {
Alexander Hansen11a1edc2025-11-12 17:31:23 +0100464 auto available =
465 msgData.find(StateDecoratorAvailability::property_names::available);
Alex.Song8f73ad72021-10-07 00:18:27 +0800466 if (available == msgData.end())
467 {
468 return 0;
469 }
470 bool asserted = std::get<bool>(available->second);
471 owner->setAvailable(asserted);
472 if (!asserted)
473 {
474 // A thermal controller will continue its PID calculation and not
475 // trigger a 'failsafe' when some inputs are unavailable.
476 // So, forced to clear the value here to prevent a historical
477 // value to participate in a latter PID calculation.
478 owner->updateValue(std::numeric_limits<double>::quiet_NaN(), true);
479 }
480 }
Alexander Hansen11a1edc2025-11-12 17:31:23 +0100481 else if (msgSensor == StateDecoratorOperationalStatus::interface)
James Feist4b36f262020-07-07 16:56:41 -0700482 {
Alexander Hansen11a1edc2025-11-12 17:31:23 +0100483 auto functional = msgData.find(
484 StateDecoratorOperationalStatus::property_names::functional);
James Feist4b36f262020-07-07 16:56:41 -0700485 if (functional == msgData.end())
486 {
487 return 0;
488 }
489 bool asserted = std::get<bool>(functional->second);
490 owner->setFunctional(asserted);
491 }
Patrick Venture863b9242018-03-08 08:29:23 -0800492
493 return 0;
494}
Patrick Ventured0c75662018-06-12 19:03:21 -0700495
Harvey.Wua1ae4fa2022-10-28 17:38:35 +0800496int dbusHandleSignal(sd_bus_message* msg, void* usrData,
497 [[maybe_unused]] sd_bus_error* err)
Patrick Ventured0c75662018-06-12 19:03:21 -0700498{
Patrick Williamsb228bc32022-07-22 19:26:56 -0500499 auto sdbpMsg = sdbusplus::message_t(msg);
Patrick Ventured0c75662018-06-12 19:03:21 -0700500 DbusPassive* obj = static_cast<DbusPassive*>(usrData);
501
Patrick Venture7af157b2018-10-30 11:24:40 -0700502 return handleSensorValue(sdbpMsg, obj);
Patrick Ventured0c75662018-06-12 19:03:21 -0700503}
Patrick Venturea0764872020-08-08 07:48:43 -0700504
505} // namespace pid_control