Support MAX34451, fix sensor type, enum issues
Add support for MAX34451 power sequencers, as well as fix some issues
with substring matching with regards to hwmon file prefix (sensor type)
and hwmon file suffix (sensor enumeration).
e.g vout11 , vout would be the sensor type and 11 would be the
enumeration.
Test:
Reboot BMC on a system with a MAX34451 present
which published the following sysfs hwmon labels,
e.g grep -H "" /sys/class/hwmon/hwmonXX/*_label
in10_label:vout12
in11_label:vout13
in12_label:vout16
in1_label:vout1
in2_label:vout2
in3_label:vout4
in4_label:vout5
in5_label:vout6
in6_label:vout7
in7_label:vout9
in8_label:vout10
in9_label:vout11
then did dbusctl --no-pager tree xyz.openbmc_project.PSUSensor
and saw the correct corresponding output voltage paths.
Before the patch having an enumeration > 9 would cause issues.
Change-Id: I9a82eea11f54266003c673013d0fed131f2f11fc
Signed-off-by: Jason Ling <jasonling@google.com>
diff --git a/include/sensor.hpp b/include/sensor.hpp
index 641d390..be17d4c 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -56,14 +56,12 @@
setInitialProperties(std::shared_ptr<sdbusplus::asio::connection>& conn)
{
createAssociation(association, configurationPath);
-
sensorInterface->register_property("MaxValue", maxValue);
sensorInterface->register_property("MinValue", minValue);
sensorInterface->register_property(
"Value", value, [&](const double& newValue, double& oldValue) {
return setSensorValue(newValue, oldValue);
});
-
for (auto& threshold : thresholds)
{
std::shared_ptr<sdbusplus::asio::dbus_interface> iface;
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index 400c514..e364a24 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -13,7 +13,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
*/
-
#include <PSUEvent.hpp>
#include <PSUSensor.hpp>
#include <Utils.hpp>
@@ -27,11 +26,12 @@
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
-static constexpr std::array<const char*, 1> sensorTypes = {
- "xyz.openbmc_project.Configuration.pmbus"};
+static constexpr std::array<const char*, 2> sensorTypes = {
+ "xyz.openbmc_project.Configuration.pmbus",
+ "xyz.openbmc_project.Configuration.MAX34451"};
static std::vector<std::string> pmbusNames = {"pmbus", "pxe1610", "ina219",
- "ina230"};
+ "ina230", "max34451"};
namespace fs = std::filesystem;
static boost::container::flat_map<std::string, std::unique_ptr<PSUSensor>>
@@ -326,14 +326,26 @@
std::get<std::vector<std::string>>(findLabelObj->second);
}
+ std::regex sensorNameRegEx("([A-Za-z]+)[0-9]*_");
+ std::smatch matches;
+
for (const auto& sensorPath : sensorPaths)
{
std::string labelHead;
std::string sensorPathStr = sensorPath.string();
std::string sensorNameStr = sensorPath.filename();
- std::string sensorNameSubStr =
- sensorNameStr.substr(0, sensorNameStr.find("_") - 1);
+ std::string sensorNameSubStr{""};
+ if (std::regex_search(sensorNameStr, matches, sensorNameRegEx))
+ {
+ sensorNameSubStr = matches[1];
+ }
+ else
+ {
+ std::cerr << "Couldn't extract the alpha prefix from "
+ << sensorNameStr;
+ continue;
+ }
auto labelPath =
boost::replace_all_copy(sensorPathStr, "input", "label");
@@ -366,28 +378,35 @@
if (std::find(findLabels.begin(), findLabels.end(),
labelHead) == findLabels.end())
{
+ std::cerr << "couldn't find " << labelHead
+ << " in the Labels list\n";
continue;
}
}
/* Find out sensor name index for this label */
- uint8_t nameIndex = labelHead[labelHead.size() - 1];
- if (nameIndex > '1' && nameIndex <= '9')
+ std::regex rgx("[A-Za-z]+([0-9]+)");
+ int nameIndex{0};
+ if (std::regex_search(labelHead, matches, rgx))
{
- nameIndex -= '1';
- if (psuNames.size() <= nameIndex)
- {
- continue;
- }
+ nameIndex = std::stoi(matches[1]);
}
else
{
nameIndex = 0;
}
+ if (psuNames.size() <= nameIndex)
+ {
+ std::cerr << "Could not pair " << labelHead
+ << " with a Name field\n";
+ continue;
+ }
+
auto findProperty = labelMatch.find(labelHead);
if (findProperty == labelMatch.end())
{
+ std::cerr << "Could not find " << labelHead << "\n";
continue;
}
@@ -419,7 +438,8 @@
auto findSensorType = sensorTable.find(sensorNameSubStr);
if (findSensorType == sensorTable.end())
{
- std::cerr << "Cannot find PSU sensorType\n";
+ std::cerr << sensorNameSubStr
+ << " is not a recognize sensor file\n";
continue;
}
@@ -459,6 +479,19 @@
{"vout1", PSUProperty("Output Voltage", 255, 0, 3)},
{"vout2", PSUProperty("Output Voltage", 255, 0, 3)},
{"vout3", PSUProperty("Output Voltage", 255, 0, 3)},
+ {"vout4", PSUProperty("Output Voltage", 255, 0, 3)},
+ {"vout5", PSUProperty("Output Voltage", 255, 0, 3)},
+ {"vout6", PSUProperty("Output Voltage", 255, 0, 3)},
+ {"vout7", PSUProperty("Output Voltage", 255, 0, 3)},
+ {"vout8", PSUProperty("Output Voltage", 255, 0, 3)},
+ {"vout9", PSUProperty("Output Voltage", 255, 0, 3)},
+ {"vout10", PSUProperty("Output Voltage", 255, 0, 3)},
+ {"vout11", PSUProperty("Output Voltage", 255, 0, 3)},
+ {"vout12", PSUProperty("Output Voltage", 255, 0, 3)},
+ {"vout13", PSUProperty("Output Voltage", 255, 0, 3)},
+ {"vout14", PSUProperty("Output Voltage", 255, 0, 3)},
+ {"vout15", PSUProperty("Output Voltage", 255, 0, 3)},
+ {"vout16", PSUProperty("Output Voltage", 255, 0, 3)},
{"in1", PSUProperty("Output Voltage", 255, 0, 3)},
{"iin", PSUProperty("Input Current", 20, 0, 3)},
{"iout1", PSUProperty("Output Current", 255, 0, 3)},
@@ -468,6 +501,8 @@
{"temp1", PSUProperty("Temperature", 127, -128, 3)},
{"temp2", PSUProperty("Temperature", 127, -128, 3)},
{"temp3", PSUProperty("Temperature", 127, -128, 3)},
+ {"temp4", PSUProperty("Temperature", 127, -128, 3)},
+ {"temp5", PSUProperty("Temperature", 127, -128, 3)},
{"fan1", PSUProperty("Fan Speed 1", 30000, 0, 0)},
{"fan2", PSUProperty("Fan Speed 2", 30000, 0, 0)}};
diff --git a/src/Utils.cpp b/src/Utils.cpp
index 2d75d9d..0518f6a 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -52,8 +52,12 @@
dbusConnection->call(getManagedObjects);
reply.read(managedObj);
}
- catch (const sdbusplus::exception::exception&)
+ catch (const sdbusplus::exception::exception& e)
{
+ std::cerr << "While calling GetManagedObjects on service:"
+ << entityManagerName << " exception name:" << e.name()
+ << "and description:" << e.description()
+ << " was thrown\n";
err = true;
}