sensor: Implement sensor "ACCURACY"
Support the accuracy attribute of the sensor. Since the latest
Redfish spec needs to support the accuracy attribute of the sensor,
extend the configuration file syntax to support the accuracy value,
read the value and publish it to the new D-Bus Accuracy interface.
Also, This function will be synchronized to the dbus sensors repo in
the future.
Tested: Build phosphor-hwmon successfully
eg: The configuration accuracy in power supply is 1
~# busctl get-property xyz.openbmc_project.Hwmon-xxx.Hwmon1
/xyz/openbmc_project/sensors/power/ps0_input_power
xyz.openbmc_project.Sensor.Accuracy Accuracy
d 1
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Idd0159b75a7506001cf886f4ae8a22dbd38b1135
diff --git a/sensor.cpp b/sensor.cpp
index 2f6ee34..1d031f4 100644
--- a/sensor.cpp
+++ b/sensor.cpp
@@ -263,6 +263,22 @@
return iface;
}
+std::shared_ptr<AccuracyObject> Sensor::addAccuracy(ObjectInfo& info,
+ double accuracy)
+{
+ auto& objPath = std::get<std::string>(info);
+ auto& obj = std::get<InterfaceMap>(info);
+
+ auto& bus = *std::get<sdbusplus::bus_t*>(info);
+ auto iface = std::make_shared<AccuracyObject>(
+ bus, objPath.c_str(), AccuracyObject::action::emit_no_signals);
+
+ iface->accuracy(accuracy);
+ obj[InterfaceType::ACCURACY] = iface;
+
+ return iface;
+}
+
void gpioLock(const gpioplus::HandleInterface*&& handle)
{
handle->setValues({0});