summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--monitor/example/monitor.yaml2
-rw-r--r--monitor/fan.cpp1
-rwxr-xr-xmonitor/gen-fan-monitor-defs.py4
-rw-r--r--monitor/tach_sensor.cpp9
-rw-r--r--monitor/tach_sensor.hpp15
-rw-r--r--monitor/types.hpp13
6 files changed, 36 insertions, 8 deletions
diff --git a/monitor/example/monitor.yaml b/monitor/example/monitor.yaml
index 1692800..fc6ca5e 100644
--- a/monitor/example/monitor.yaml
+++ b/monitor/example/monitor.yaml
@@ -19,6 +19,8 @@
# - name [The name of the fan sensor]
# has_target [true|false If this sensor has a Target property for
# setting a fan speed (otherwise just for reads)]
+# target_interface [The fan target interface used by the sensor.
+# Default is "xyz.openbmc_project.Control.FanSpeed"]
# factor [The factor to multiply with target to calculate the expected
# fan speed. Default is 1 for fan speed target;
# Customized value for pwm target]
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 81d27e0..637a3ca 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -53,6 +53,7 @@ Fan::Fan(Mode mode,
*this,
std::get<sensorNameField>(s),
std::get<hasTargetField>(s),
+ std::get<targetInterfaceField>(s),
std::get<factorField>(s),
std::get<offsetField>(s),
std::get<timeoutField>(def),
diff --git a/monitor/gen-fan-monitor-defs.py b/monitor/gen-fan-monitor-defs.py
index 48cf7ec..965625b 100755
--- a/monitor/gen-fan-monitor-defs.py
+++ b/monitor/gen-fan-monitor-defs.py
@@ -36,11 +36,15 @@ const std::vector<FanDefinition> fanDefinitions
<%
#has_target is a bool, and we need a true instead of True
has_target = str(sensor['has_target']).lower()
+ target_interface = sensor.get(
+ 'target_interface',
+ 'xyz.openbmc_project.Control.FanSpeed')
factor = sensor.get('factor', 1)
offset = sensor.get('offset', 0)
%> \
SensorDefinition{"${sensor['name']}",
${has_target},
+ "${target_interface}",
${factor},
${offset}},
%endfor
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 47f4d91..d725729 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -27,7 +27,6 @@ namespace fan
namespace monitor
{
-constexpr auto FAN_SENSOR_CONTROL_INTF = "xyz.openbmc_project.Control.FanSpeed";
constexpr auto FAN_SENSOR_VALUE_INTF = "xyz.openbmc_project.Sensor.Value";
constexpr auto FAN_TARGET_PROPERTY = "Target";
constexpr auto FAN_VALUE_PROPERTY = "Value";
@@ -69,6 +68,7 @@ TachSensor::TachSensor(Mode mode,
Fan& fan,
const std::string& id,
bool hasTarget,
+ const std::string& interface,
size_t factor,
size_t offset,
size_t timeout,
@@ -78,6 +78,7 @@ TachSensor::TachSensor(Mode mode,
_name(FAN_SENSOR_PATH + id),
_invName(path(fan.getName()) / id),
_hasTarget(hasTarget),
+ _interface(interface),
_factor(factor),
_offset(offset),
_timeout(timeout),
@@ -106,7 +107,7 @@ TachSensor::TachSensor(Mode mode,
if (_hasTarget)
{
- readProperty(FAN_SENSOR_CONTROL_INTF,
+ readProperty(_interface,
FAN_TARGET_PROPERTY,
_name,
_bus,
@@ -122,7 +123,7 @@ TachSensor::TachSensor(Mode mode,
if (_hasTarget)
{
- match = getMatchString(FAN_SENSOR_CONTROL_INTF);
+ match = getMatchString(_interface);
targetSignal = std::make_unique<sdbusplus::server::match::match>(
_bus,
@@ -189,7 +190,7 @@ static void readPropertyFromMessage(sdbusplus::message::message& msg,
void TachSensor::handleTargetChange(sdbusplus::message::message& msg)
{
readPropertyFromMessage(msg,
- FAN_SENSOR_CONTROL_INTF,
+ _interface,
FAN_TARGET_PROPERTY,
_tachTarget);
diff --git a/monitor/tach_sensor.hpp b/monitor/tach_sensor.hpp
index 50951cd..2cd0f4a 100644
--- a/monitor/tach_sensor.hpp
+++ b/monitor/tach_sensor.hpp
@@ -62,6 +62,7 @@ class TachSensor
* @param[in] id - the id of the sensor
* @param[in] hasTarget - if the sensor supports
* setting the speed
+ * @param[in] interface - the interface of the target
* @param[in] factor - the factor of the sensor target
* @param[in] offset - the offset of the sensor target
* @param[in] timeout - Normal timeout value to use
@@ -72,6 +73,7 @@ class TachSensor
Fan& fan,
const std::string& id,
bool hasTarget,
+ const std::string& interface,
size_t factor,
size_t offset,
size_t timeout,
@@ -99,6 +101,14 @@ class TachSensor
}
/**
+ * @brief Returns the interface of the sensor target
+ */
+ inline std::string getInterface() const
+ {
+ return _interface;
+ }
+
+ /**
* @brief Returns the factor of the sensor target
*/
inline size_t getFactor() const
@@ -237,6 +247,11 @@ class TachSensor
const bool _hasTarget;
/**
+ * @brief The interface that the target implements
+ */
+ const std::string _interface;
+
+ /**
* @brief The factor of target to get fan rpm
*/
const size_t _factor;
diff --git a/monitor/types.hpp b/monitor/types.hpp
index 5993c53..b4baa9c 100644
--- a/monitor/types.hpp
+++ b/monitor/types.hpp
@@ -18,10 +18,15 @@ using CreateGroupFunction =
constexpr auto sensorNameField = 0;
constexpr auto hasTargetField = 1;
-constexpr auto factorField = 2;
-constexpr auto offsetField = 3;
-
-using SensorDefinition = std::tuple<std::string, bool, size_t, size_t>;
+constexpr auto targetInterfaceField = 2;
+constexpr auto factorField = 3;
+constexpr auto offsetField = 4;
+
+using SensorDefinition = std::tuple<std::string,
+ bool,
+ std::string,
+ size_t,
+ size_t>;
constexpr auto fanNameField = 0;
constexpr auto timeoutField = 1;
OpenPOWER on IntegriCloud