summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2018-03-02 18:46:39 +0530
committerTom Joseph <tomjoseph@in.ibm.com>2018-03-16 16:14:05 +0000
commit22102153dccd4ae5fcd4ffca06c67bb2842255fe (patch)
tree872f3f5fda2cdce8462e3fd385b00001dd68ac09
parentaf8a09805df29e486cf5a195bc81ff0fadbe6f15 (diff)
downloadphosphor-host-ipmid-22102153dccd4ae5fcd4ffca06c67bb2842255fe.tar.gz
phosphor-host-ipmid-22102153dccd4ae5fcd4ffca06c67bb2842255fe.zip
sensor: Fix set sensor reading for analog sensors
Tested: Set temperature sensor to sensor object Change-Id: I77b8dcd6f298ca7b09aac475c2e8da4af5825940 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
-rw-r--r--sensordatahandler.hpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp
index a3253b9..e36b71a 100644
--- a/sensordatahandler.hpp
+++ b/sensordatahandler.hpp
@@ -271,24 +271,18 @@ template<typename T>
ipmi_ret_t readingData(const SetSensorReadingReq& cmdData,
const Info& sensorInfo)
{
- auto msg = makeDbusMsg(
- "org.freedesktop.DBus.Properties",
- sensorInfo.sensorPath,
- "Set",
- sensorInfo.sensorInterface);
+ T raw_value = (sensorInfo.coefficientM * cmdData.reading) +
+ sensorInfo.scaledOffset;
- const auto& interface = sensorInfo.propertyInterfaces.begin();
- msg.append(interface->first);
+ raw_value *= pow(10, sensorInfo.exponentR - sensorInfo.scale);
- ipmi::sensor::Multiplier m = sensorInfo.coefficientM;
- if (0 == m)
- {
- m = 1; // Avoid * 0
- }
+ auto msg = makeDbusMsg("org.freedesktop.DBus.Properties",
+ sensorInfo.sensorPath,
+ "Set",
+ sensorInfo.sensorInterface);
- // TODO: Refactor this into a generated function depending on the type
- // of conversion for the value between IPMI and dbus.
- T raw_value = (m * cmdData.reading) + sensorInfo.scaledOffset;
+ const auto& interface = sensorInfo.propertyInterfaces.begin();
+ msg.append(interface->first);
for (const auto& property : interface->second)
{
OpenPOWER on IntegriCloud