Using readPath dbuspath in getMatch function
- If the "name" setting is not same as dbus sensor name,
it has problem when getMatch function.
For example:
if json setting like below,
{
"name": "fan00",
"type": "fan",
"readPath": "/xyz/openbmc_project/sensors/fan_tach/fan0_tach",
"writePath": "/xyz/openbmc_project/sensors/fan_tach/fan0_pwm",
"min": 0,
"max": 255
}
the swampd will start failed, log like below,
swampd[17273]: Sensor: fan00 fan /xyz/openbmc_project/sensors/fan_tach/fan0_tach /xyz/openbmc_project/sensors/fan_tach/fan0_pwm
swampd[17273]: ObjectMapper call failure
Signed-off-by: Harvey.Wu <Harvey.Wu@quantatw.com>
Change-Id: I08cd374ea7447148e4aeff7b06b288957260cbd2
diff --git a/dbus/dbuspassive.cpp b/dbus/dbuspassive.cpp
index 038b1d7..182a9a5 100644
--- a/dbus/dbuspassive.cpp
+++ b/dbus/dbuspassive.cpp
@@ -48,7 +48,15 @@
/* Need to get the scale and initial value */
/* service == busname */
- std::string path = getSensorPath(type, id);
+ std::string path;
+ if (info->readPath.empty())
+ {
+ path = getSensorPath(type, id);
+ }
+ else
+ {
+ path = info->readPath;
+ }
SensorProperties settings;
bool failed;
@@ -84,7 +92,7 @@
const SensorProperties& settings, bool failed, const std::string& path,
const std::shared_ptr<DbusPassiveRedundancy>& redundancy) :
ReadInterface(),
- _signal(bus, getMatch(type, id).c_str(), dbusHandleSignal, this), _id(id),
+ _signal(bus, getMatch(path).c_str(), dbusHandleSignal, this), _id(id),
_helper(std::move(helper)), _failed(failed), path(path),
redundancy(redundancy)
diff --git a/dbus/dbusutil.cpp b/dbus/dbusutil.cpp
index 9132a60..a1f0a95 100644
--- a/dbus/dbusutil.cpp
+++ b/dbus/dbusutil.cpp
@@ -111,13 +111,13 @@
return std::string("/xyz/openbmc_project/sensors/" + layer + "/" + id);
}
-std::string getMatch(const std::string& type, const std::string& id)
+std::string getMatch(const std::string& path)
{
return std::string("type='signal',"
"interface='org.freedesktop.DBus.Properties',"
"member='PropertiesChanged',"
"path='" +
- getSensorPath(type, id) + "'");
+ path + "'");
}
bool validType(const std::string& type)
diff --git a/dbus/dbusutil.hpp b/dbus/dbusutil.hpp
index 7faf4fc..5012af0 100644
--- a/dbus/dbusutil.hpp
+++ b/dbus/dbusutil.hpp
@@ -29,7 +29,7 @@
};
std::string getSensorPath(const std::string& type, const std::string& id);
-std::string getMatch(const std::string& type, const std::string& id);
+std::string getMatch(const std::string& path);
void scaleSensorReading(const double min, const double max, double& value);
bool validType(const std::string& type);