summaryrefslogtreecommitdiffstats
path: root/sensordatahandler.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'sensordatahandler.hpp')
-rw-r--r--sensordatahandler.hpp47
1 files changed, 35 insertions, 12 deletions
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp
index 6d80f9a..99c3ae9 100644
--- a/sensordatahandler.hpp
+++ b/sensordatahandler.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "config.h"
+
#include "sensorhandler.hpp"
#include <cmath>
@@ -13,8 +15,6 @@ namespace ipmi
namespace sensor
{
-namespace variant_ns = sdbusplus::message::variant_ns;
-
using Assertion = uint16_t;
using Deassertion = uint16_t;
using AssertionSet = std::pair<Assertion, Deassertion>;
@@ -156,7 +156,6 @@ GetSensorResponse readingAssertion(const Info& sensorInfo)
{
sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
GetSensorResponse response{};
- auto responseData = reinterpret_cast<GetReadingResponse*>(response.data());
auto service = ipmi::getService(bus, sensorInfo.sensorInterface,
sensorInfo.sensorPath);
@@ -166,8 +165,7 @@ GetSensorResponse readingAssertion(const Info& sensorInfo)
sensorInfo.propertyInterfaces.begin()->first,
sensorInfo.propertyInterfaces.begin()->second.begin()->first);
- setAssertionBytes(static_cast<uint16_t>(variant_ns::get<T>(propValue)),
- responseData);
+ setAssertionBytes(static_cast<uint16_t>(std::get<T>(propValue)), &response);
return response;
}
@@ -184,26 +182,51 @@ template <typename T>
GetSensorResponse readingData(const Info& sensorInfo)
{
sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
+
GetSensorResponse response{};
- auto responseData = reinterpret_cast<GetReadingResponse*>(response.data());
- enableScanning(responseData);
+ enableScanning(&response);
auto service = ipmi::getService(bus, sensorInfo.sensorInterface,
sensorInfo.sensorPath);
+#ifdef UPDATE_FUNCTIONAL_ON_FAIL
+ // Check the OperationalStatus interface for functional property
+ if (sensorInfo.propertyInterfaces.begin()->first ==
+ "xyz.openbmc_project.Sensor.Value")
+ {
+ bool functional = true;
+ try
+ {
+ auto funcValue = ipmi::getDbusProperty(
+ bus, service, sensorInfo.sensorPath,
+ "xyz.openbmc_project.State.Decorator.OperationalStatus",
+ "Functional");
+ functional = std::get<bool>(funcValue);
+ }
+ catch (...)
+ {
+ // No-op if Functional property could not be found since this
+ // check is only valid for Sensor.Value read for hwmonio
+ }
+ if (!functional)
+ {
+ throw SensorFunctionalError();
+ }
+ }
+#endif
+
auto propValue = ipmi::getDbusProperty(
bus, service, sensorInfo.sensorPath,
sensorInfo.propertyInterfaces.begin()->first,
sensorInfo.propertyInterfaces.begin()->second.begin()->first);
- double value = variant_ns::get<T>(propValue) *
+ double value = std::get<T>(propValue) *
std::pow(10, sensorInfo.scale - sensorInfo.exponentR);
auto rawData = static_cast<uint8_t>((value - sensorInfo.scaledOffset) /
sensorInfo.coefficientM);
-
- setReading(rawData, responseData);
+ setReading(rawData, &response);
return response;
}
@@ -252,7 +275,7 @@ ipmi_ret_t readingAssertion(const SetSensorReadingReq& cmdData,
for (const auto& property : interface->second)
{
msg.append(property.first);
- sdbusplus::message::variant<T> value =
+ std::variant<T> value =
(cmdData.assertOffset8_14 << 8) | cmdData.assertOffset0_7;
msg.append(value);
}
@@ -283,7 +306,7 @@ ipmi_ret_t readingData(const SetSensorReadingReq& cmdData,
for (const auto& property : interface->second)
{
msg.append(property.first);
- sdbusplus::message::variant<T> value = raw_value;
+ std::variant<T> value = raw_value;
msg.append(value);
}
return updateToDbus(msg);
OpenPOWER on IntegriCloud