Add PSU PWM sensor to support FSC
Add PSU PWM sensor to allow FSC control PSU fan pwm.
Tested:
Change property Target to 100 in dbus interface xyz.openbmc_project.Control.FanPwm
path /xyz/openbmc_project/control/fanpwm/Pwm_PSU1_Fan_1, the value in
/sys/class/hwmon/hwmonx/fan1_target also become 100, and value property in interface
/xyz/openbmc_project/sensors/fan_pwm/Pwm_PSU1_Fan_1 become 39.2157
Run ipmitool sensor list, bellow sensors will show like:
Pwm PSU1 Fan 1 | 39.200 | unspecified | ok | na | na | na | na | na | na
Pwm PSU2 Fan 1 | 0.000 | unspecified | ok | na | na | na | na | na | na
Signed-off-by: Cheng C Yang <cheng.c.yang@linux.intel.com>
Change-Id: I6a4d50912a190297dbcf4a4e5c511607f71cb0c0
diff --git a/src/PwmSensor.cpp b/src/PwmSensor.cpp
index b157d52..6402ad0 100644
--- a/src/PwmSensor.cpp
+++ b/src/PwmSensor.cpp
@@ -24,15 +24,12 @@
static constexpr size_t pwmMax = 255;
static constexpr size_t pwmMin = 0;
-PwmSensor::PwmSensor(const std::string& sysPath,
+PwmSensor::PwmSensor(const std::string& name, const std::string& sysPath,
sdbusplus::asio::object_server& objectServer,
const std::string& sensorConfiguration) :
- sysPath(sysPath),
- objectServer(objectServer)
+ name(name),
+ sysPath(sysPath), objectServer(objectServer)
{
- // strip off index from path
- name = "Pwm_" + sysPath.substr(sysPath.find_last_of("pwm") + 1);
-
// add interface under sensor and Control.FanPwm as Control is used
// in obmc project, also add sensor so it can be viewed as a sensor
sensorInterface = objectServer.add_interface(