Make hwmon work with double or int64 interface
Deduce type based on interface using decltype
and if it is double apply scale to the value.
Tested-by: Noticed that on dbus using busctl and debug
server that doubles were produced and scaled.
Also verifed that hwmon still produced int64_t values when
building with current phosphor-dbus-interfaces.
Change-Id: I00e21d5ef0ea6cee0eb30baa0b39cde95e7f4a86
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/sensor.hpp b/sensor.hpp
index 3f38c33..37cf035 100644
--- a/sensor.hpp
+++ b/sensor.hpp
@@ -73,7 +73,7 @@
*
* @return - Adjusted sensor value
*/
- int64_t adjustValue(int64_t value);
+ SensorValueType adjustValue(SensorValueType value);
/**
* @brief Add value interface and value property for sensor
@@ -113,6 +113,16 @@
*/
void lockGpio();
+ /**
+ * @brief Get the scale from the sensor.
+ *
+ * @return - Scale value
+ */
+ inline int64_t getScale(void)
+ {
+ return scale;
+ }
+
private:
/** @brief Sensor object's identifiers */
SensorSet::key_type sensor;
@@ -131,6 +141,9 @@
/** @brief default pause after unlocking gpio. */
static constexpr std::chrono::milliseconds pause{500};
+
+ /** @brief sensor scale from configuration. */
+ int64_t scale;
};
} // namespace sensor