Handle missing MinValue/MaxValue
In the existing implementation, if MinValue/MaxValue
property is missing on dbus and if one of the
warning or critical thresholds are set, then the
readings are scaled differently in `ipmiSenGetSensorReading`
than the values reported for sensor attributes(B, M, bExp, rExp)
in `ipmiStorageGetSDR`.
Signed-off-by: Shakeeb Pasha <shakeebbk@gmail.com>
Change-Id: I9cd10224985874d8e200b6dcfaf0e9394575d9d9
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index 21f4cb9..3cebeb0 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -1529,22 +1529,9 @@
record.body.entity_id = entityId;
record.body.entity_instance = entityInstance;
- auto maxObject = sensorObject->second.find("MaxValue");
- auto minObject = sensorObject->second.find("MinValue");
-
- // If min and/or max are left unpopulated,
- // then default to what a signed byte would be, namely (-128,127) range.
- auto max = static_cast<double>(std::numeric_limits<int8_t>::max());
- auto min = static_cast<double>(std::numeric_limits<int8_t>::lowest());
- if (maxObject != sensorObject->second.end())
- {
- max = std::visit(VariantToDoubleVisitor(), maxObject->second);
- }
-
- if (minObject != sensorObject->second.end())
- {
- min = std::visit(VariantToDoubleVisitor(), minObject->second);
- }
+ double max = 0;
+ double min = 0;
+ getSensorMaxMin(sensorMap, max, min);
int16_t mValue = 0;
int8_t rExp = 0;