Modified sensorConfig map index name about fan
- Like the phosphor-pid-control github issue #19,
if a fan is set as input sensor and has multiple output setting,
there are some problems when building sensorConfig map that
only have the last setting in sensorConfig map.
TEST:
https://gist.github.com/harveyquta/e2d3c91bf86299e5301bfb080711dbb4
Signed-off-by: Harvey.Wu <Harvey.Wu@quantatw.com>
Change-Id: I4f070888ce64c45a420467c6a07fcbd8312aa7a0
diff --git a/dbus/dbusconfiguration.cpp b/dbus/dbusconfiguration.cpp
index 990dd53..ef990c9 100644
--- a/dbus/dbusconfiguration.cpp
+++ b/dbus/dbusconfiguration.cpp
@@ -637,16 +637,16 @@
inputSensorInterface.second;
const std::string& inputSensorPath =
inputSensorInterface.first;
- std::string inputSensorName =
- getSensorNameFromPath(inputSensorPath);
- auto& config = sensorConfig[inputSensorName];
- inputSensorNames.push_back(inputSensorName);
- config.type = pidClass;
- config.readPath = inputSensorInterface.first;
// todo: maybe un-hardcode this if we run into slower
// timeouts with sensors
- if (config.type == "temp")
+ if (pidClass == "temp")
{
+ std::string inputSensorName =
+ getSensorNameFromPath(inputSensorPath);
+ auto& config = sensorConfig[inputSensorName];
+ inputSensorNames.push_back(inputSensorName);
+ config.type = pidClass;
+ config.readPath = inputSensorInterface.first;
config.timeout = 0;
config.ignoreDbusMinMax = true;
config.unavailableAsFailed = unavailableAsFailed;
@@ -696,6 +696,7 @@
std::string fanSensorName;
std::string pwmPath;
std::string pwmInterface;
+ std::string pwmSensorName;
if (singlePwm)
{
/* if just a single output(pwm) is provided then use
@@ -726,7 +727,12 @@
const std::string& fanPath =
inputSensorInterfaces.at(idx).first;
fanSensorName = getSensorNameFromPath(fanPath);
- auto& fanConfig = sensorConfig[fanSensorName];
+ pwmSensorName = getSensorNameFromPath(pwmPath);
+ std::string fanPwmIndex = fanSensorName + pwmSensorName;
+ inputSensorNames.push_back(fanPwmIndex);
+ auto& fanConfig = sensorConfig[fanPwmIndex];
+ fanConfig.type = pidClass;
+ fanConfig.readPath = fanPath;
fanConfig.writePath = pwmPath;
// todo: un-hardcode this if there are fans with
// different ranges