monitor: Support target_path option in configuration file
The target path containing the interface
xyz.openbmc_project.control.FanPwm or
xyz.openbmc_project.control.FanSpeed can be different between
phosphor-hwmon and dbus-sensor.
In phosphor-hwmon, it is "/xyz/openbmc_project/sensors/fan_tach/".
In dbus-sensor, it is "/xyz/openbmc_project/control/fanpwm/".
This commit supports making this path configurable via "target_path"
as a full object path.
By default, it is the same as the fan tach object path.
Signed-off-by: Chau Ly <chaul@amperecomputing.com>
Change-Id: I2658a462dd49a98ad77d684f2927e6ccae21cd15
diff --git a/monitor/json_parser.cpp b/monitor/json_parser.cpp
index 1144998..e3d23d9 100644
--- a/monitor/json_parser.cpp
+++ b/monitor/json_parser.cpp
@@ -146,6 +146,12 @@
{
targetIntf = sensor["target_interface"].get<std::string>();
}
+ // Target path is optional
+ std::string targetPath;
+ if (sensor.contains("target_path"))
+ {
+ targetPath = sensor["target_path"].get<std::string>();
+ }
// Factor is optional and defaults to 1
auto factor = 1.0;
if (sensor.contains("factor"))
@@ -173,7 +179,7 @@
sensorDefs.emplace_back(std::tuple(
sensor["name"].get<std::string>(), sensor["has_target"].get<bool>(),
- targetIntf, factor, offset, threshold, ignoreAboveMax));
+ targetIntf, targetPath, factor, offset, threshold, ignoreAboveMax));
}
return sensorDefs;