Update sdrutils.hpp for use outside of intel-ipmi-oem
This change makes some minor improvements to match what was
up for review in phosphor-host-ipmid and removes sdrutils.hpp
dependencies on local files so it can be used outside of
intel-ipmi-oem.
Change-Id: Id126069cbe348fac4923c82f99ba96ebd7c35902
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
diff --git a/include/sdrutils.hpp b/include/sdrutils.hpp
index 7c7b311..369dc8b 100644
--- a/include/sdrutils.hpp
+++ b/include/sdrutils.hpp
@@ -18,7 +18,6 @@
#include <boost/container/flat_map.hpp>
#include <cstring>
#include <phosphor-logging/log.hpp>
-#include <storagecommands.hpp>
#pragma once
@@ -52,7 +51,7 @@
dbus.new_method_call("xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTree");
- static const auto depth = 2;
+ static constexpr const auto depth = 2;
static constexpr std::array<const char*, 3> interfaces = {
"xyz.openbmc_project.Sensor.Value",
"xyz.openbmc_project.Sensor.Threshold.Warning",
@@ -65,10 +64,9 @@
subtree.clear();
mapperReply.read(subtree);
}
- catch (sdbusplus::exception_t&)
+ catch (sdbusplus::exception_t& e)
{
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "getSensorSubtree: Error calling mapper");
+ phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
return false;
}
return true;
@@ -82,6 +80,16 @@
}
};
+enum class SensorTypeCodes : uint8_t
+{
+ reserved = 0x0,
+ temperature = 0x1,
+ voltage = 0x2,
+ current = 0x3,
+ fan = 0x4,
+ other = 0xB,
+};
+
const static boost::container::flat_map<const char*, SensorTypeCodes, CmpStr>
sensorTypes{{{"temperature", SensorTypeCodes::temperature},
{"voltage", SensorTypeCodes::voltage},
diff --git a/include/storagecommands.hpp b/include/storagecommands.hpp
index 0d32ea5..063f2a8 100644
--- a/include/storagecommands.hpp
+++ b/include/storagecommands.hpp
@@ -95,16 +95,6 @@
words = 0x1
};
-enum class SensorTypeCodes : uint8_t
-{
- reserved = 0x0,
- temperature = 0x1,
- voltage = 0x2,
- current = 0x3,
- fan = 0x4,
- other = 0xB,
-};
-
enum class SensorUnits : uint8_t
{
unspecified = 0x0,