summaryrefslogtreecommitdiff
path: root/gpiodaemon
diff options
context:
space:
mode:
authorRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2019-04-04 11:02:47 +0300
committerRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2019-04-08 07:16:56 +0300
commit785f19b128794611574ea6c18805740fb851ecff (patch)
tree4fbe051591cdb868fc8ce3769a4c2ea2abb811ac /gpiodaemon
parent8f2613f77dbd288c93f9bf8bfb06473406f615f9 (diff)
downloadprovingground-785f19b128794611574ea6c18805740fb851ecff.tar.xz
Do case insentive comparisons & representations
Code updated to do case insentive comparisons for direction & polarity, when read from Entity-manager. Tested: 1. Verified gpiodaemon exposes all the objects as before using busctl 2. verified ipmitool chassis status still works (ascertaining the whole flow is good) Change-Id: I6955b00b1d2ccd6add42ad30ba3ae3753655068e Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
Diffstat (limited to 'gpiodaemon')
-rw-r--r--gpiodaemon/src/gpiodaemon.cpp41
1 files changed, 31 insertions, 10 deletions
diff --git a/gpiodaemon/src/gpiodaemon.cpp b/gpiodaemon/src/gpiodaemon.cpp
index 5600f69..60bb5e8 100644
--- a/gpiodaemon/src/gpiodaemon.cpp
+++ b/gpiodaemon/src/gpiodaemon.cpp
@@ -70,15 +70,35 @@ void GpioManager::addObject(const std::string& path)
std::string gpioName =
sdbusplus::message::variant_ns::get<std::string>(
nameFind->second);
- bool inverted =
+ bool inverted = boost::iequals(
sdbusplus::message::variant_ns::get<std::string>(
- polarityFind->second) == "Low";
+ polarityFind->second),
+ "Low");
std::string direction =
sdbusplus::message::variant_ns::get<std::string>(
directionFind->second);
boost::replace_all(gpioName, " ", "_");
- boost::algorithm::to_lower(direction);
+
+ if (boost::iequals(direction, "Input"))
+ {
+ direction = "in";
+ }
+ else if (boost::iequals(direction, "Out") ||
+ boost::iequals(direction, "Both"))
+ {
+ direction = "out";
+ }
+ else
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "ERROR Illegal direction for GPIO",
+ phosphor::logging::entry("GPIO_NAME=%s",
+ gpioName.c_str()),
+ phosphor::logging::entry("DIRECTION=%s",
+ direction.c_str()));
+ }
+
if (gpioMonitorList.find(gpioName) != gpioMonitorList.end())
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -176,13 +196,16 @@ GpioState::GpioState(const std::string& name_, const uint64_t& number_,
"Direction", direction,
// Override set
[this](const std::string& req, std::string& propertyValue) {
- if (!ignore && direction != req)
+ if (req == "in" || req == "out")
{
- direction = req;
- this->gpio.setDirection(req);
+ if (!ignore && direction != req)
+ {
+ direction = req;
+ this->gpio.setDirection(req);
- propertyValue = req;
- return 1;
+ propertyValue = req;
+ return 1;
+ }
}
return 0;
},
@@ -337,8 +360,6 @@ int main()
{
if (gpioConfigInterface == objectInterfaces.first)
{
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "New configuration detected. Updating gpiodaemon.");
gpioMgr.addObject(objectPath.str);
}
}