Fix for PSU input sensors
PSU1_input_power and PSU1_In_Voltage sensors are not populated in
busctl tree xyz.openbmc_project.PSUSensor.
Its happening as the sensor names searched with "sensorNameSubStr" in
code and it was populating PSUProperty as "Output Power" for Power Input
sensors(pin) as well.
So update "sensorNameSubStr" with "labelHead" and add the strings to
labelMatch as per the PSU configuration file to populate pin sensors.
Tested:
Verified using ipmitool sensor list.
~#ipmitool sensor list | grep -i psu
PSU1_In_Current | 1.872 |Amps |ok|na | na|na|na|na| na
PSU1_Out_Current | 30.000 |Amps |ok|na |na|na| 164.000|180.000|na
Pwm_PSU1_Fan_1|39.984 |unspecified |ok|na|na|na|na|na| na
Pwm_PSU1_Fan_2|39.984 |unspecified |ok|na|na|na|na|na| na
PSU1_Fan_Speed_1 | 8142.000|RPM |ok|na|na|na|na|na| na
PSU1_Fan_Speed_2 | 6962.000|RPM |ok|na|na|na|na|na| na
PSU1_Input_Power | 401.200 |Watts|ok|na|na|na| 1947.000| 2147.600 | na
PSU1_Out_Power|354.000 |Watts |ok|na|na|na|na|na| na
PSU1_Temperature | 26.000 |degrees C |ok|na|na|na| 73.000 |78.000 |na
PSU1_In_Voltage | 207.680 |Volts |ok|na|na|na|na|na| na
Signed-off-by: Jitendra Tripathy <jitendra.kumarx.tripathy@intel.com>
Signed-off-by: Jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
Change-Id: Idc7099e28632342c3c6591a63da6cd2129cd9f63
diff --git a/src/psu/PSUSensorMain.cpp b/src/psu/PSUSensorMain.cpp
index 0df7d41..d125470 100644
--- a/src/psu/PSUSensorMain.cpp
+++ b/src/psu/PSUSensorMain.cpp
@@ -51,6 +51,7 @@
#include <fstream>
#include <functional>
#include <iostream>
+#include <iterator>
#include <memory>
#include <regex>
#include <stdexcept>
@@ -676,14 +677,18 @@
continue;
}
}
-
- auto findProperty = labelMatch.find(sensorNameSubStr);
+ auto it = std::find_if(labelHead.begin(), labelHead.end(),
+ static_cast<int (*)(int)>(std::isdigit));
+ std::string_view labelHeadView(
+ labelHead.data(), std::distance(labelHead.begin(), it));
+ auto findProperty =
+ labelMatch.find(static_cast<std::string>(labelHeadView));
if (findProperty == labelMatch.end())
{
if constexpr (debug)
{
std::cerr << "Could not find matching default property for "
- << sensorNameSubStr << "\n";
+ << labelHead << "\n";
}
continue;
}