summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarri Devender Rao <devenrao@in.ibm.com>2018-02-11 08:45:00 -0600
committerTom Joseph <tomjoseph@in.ibm.com>2018-02-15 05:36:28 +0000
commitce6a795a8ecc7755290ea4bcef4bf3340a331b49 (patch)
treed0bb902c69cf876e48427055a44122f24f63e1d3
parent3e6a769b552c0cf1ec6dd60b2e5a6c6fed9b46a5 (diff)
downloadphosphor-host-ipmid-ce6a795a8ecc7755290ea4bcef4bf3340a331b49.tar.gz
phosphor-host-ipmid-ce6a795a8ecc7755290ea4bcef4bf3340a331b49.zip
Fix failure in reading power value during PowerOff state
D-Bus sensor object to read power value is not created during PowerOff state. Fixed to return 0 power value if sensor object is not present. Change-Id: Ibe340cab0483c7a711081197b932aaba0408d333 Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
-rw-r--r--dcmihandler.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/dcmihandler.cpp b/dcmihandler.cpp
index 11befdc..bfc8466 100644
--- a/dcmihandler.cpp
+++ b/dcmihandler.cpp
@@ -1037,18 +1037,28 @@ int64_t getPowerReading(sdbusplus::bus::bus& bus)
elog<InternalFailure>();
}
- auto service = ipmi::getService(bus, SENSOR_VALUE_INTF, objectPath);
-
- //Read the sensor value and scale properties
- auto properties = ipmi::getAllDbusProperties(
- bus, service, objectPath, SENSOR_VALUE_INTF);
- auto power = properties[SENSOR_VALUE_PROP].get<int64_t>();
- auto scale = properties[SENSOR_SCALE_PROP].get<int64_t>();
+ // Return default value if failed to read from D-Bus object
+ int64_t power = 0;
+ try
+ {
+ auto service = ipmi::getService(bus, SENSOR_VALUE_INTF, objectPath);
- // Power reading needs to be scaled with the Scale value using the formula
- // Value * 10^Scale.
- power *= std::pow(10, scale);
+ //Read the sensor value and scale properties
+ auto properties = ipmi::getAllDbusProperties(
+ bus, service, objectPath, SENSOR_VALUE_INTF);
+ auto value = properties[SENSOR_VALUE_PROP].get<int64_t>();
+ auto scale = properties[SENSOR_SCALE_PROP].get<int64_t>();
+ // Power reading needs to be scaled with the Scale value using the
+ // formula Value * 10^Scale.
+ power = value * std::pow(10, scale);
+ }
+ catch (std::exception& e)
+ {
+ log<level::INFO>("Failure to read power value from D-Bus object",
+ entry("OBJECT_PATH=%s", objectPath),
+ entry("INTERFACE=%s", SENSOR_VALUE_INTF));
+ }
return power;
}
OpenPOWER on IntegriCloud