Add in a delay before setting present to true
When a power supply is inserted, allow for a time delay before starting
the fault checks. This will give the individual servicing a power supply
some time to insert the supply and then apply power.
Change-Id: Ic957be927cea26a6c011a0a634f84093e040b454
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/power-supply/main.cpp b/power-supply/main.cpp
index 2aa7a7e..32b5149 100644
--- a/power-supply/main.cpp
+++ b/power-supply/main.cpp
@@ -85,13 +85,17 @@
// the sysfs files will only be updated by the ibm-cffps device driver once
// a second, so round up that delay to 2 seconds.
std::chrono::seconds powerOnDelay(2);
+ // Timer to delay setting internal presence tracking. Allows for servicing
+ // the power supply.
+ std::chrono::seconds presentDelay(2);
auto psuDevice = std::make_unique<psu::PowerSupply>(objname,
std::move(instance),
std::move(objpath),
std::move(invpath),
bus,
eventPtr,
- powerOnDelay);
+ powerOnDelay,
+ presentDelay);
auto pollInterval = std::chrono::milliseconds(1000);
DeviceMonitor mainloop(std::move(psuDevice), eventPtr, pollInterval);
diff --git a/power-supply/power_supply.cpp b/power-supply/power_supply.cpp
index e611315..bc76050 100644
--- a/power-supply/power_supply.cpp
+++ b/power-supply/power_supply.cpp
@@ -45,9 +45,15 @@
const std::string& invpath,
sdbusplus::bus::bus& bus,
event::Event& e,
- std::chrono::seconds& t)
+ std::chrono::seconds& t,
+ std::chrono::seconds& p)
: Device(name, inst), monitorPath(objpath), pmbusIntf(objpath),
- inventoryPath(invpath), bus(bus), event(e), powerOnInterval(t),
+ inventoryPath(invpath), bus(bus), event(e), presentInterval(p),
+ presentTimer(e, [this]()
+ {
+ this->present = true;
+ }),
+ powerOnInterval(t),
powerOnTimer(e, [this]()
{
this->powerOn = true;
@@ -156,6 +162,11 @@
if (present)
{
clearFaults();
+ presentTimer.start(presentInterval, Timer::TimerType::oneshot);
+ }
+ else
+ {
+ presentTimer.stop();
}
}
diff --git a/power-supply/power_supply.hpp b/power-supply/power_supply.hpp
index a77912e..3da02b4 100644
--- a/power-supply/power_supply.hpp
+++ b/power-supply/power_supply.hpp
@@ -40,13 +40,17 @@
* @param[in] bus - D-Bus bus object
* @param[in] e - event object
* @param[in] t - time to allow power supply to assert PG#
+ * @param[in] p - time to allow power supply presence state to
+ * settle/deglitch and allow for application of power
+ * prior to fault checking
*/
PowerSupply(const std::string& name, size_t inst,
const std::string& objpath,
const std::string& invpath,
sdbusplus::bus::bus& bus,
event::Event& e,
- std::chrono::seconds& t);
+ std::chrono::seconds& t,
+ std::chrono::seconds& p);
/**
* Power supply specific function to analyze for faults/errors.
@@ -96,6 +100,27 @@
/** @brief Used to subscribe to D-Bus property changes for Present */
std::unique_ptr<sdbusplus::bus::match_t> presentMatch;
+ /** @brief The sd_event structure used by the power on and present
+ * timers. */
+ event::Event& event;
+
+ /**
+ * @brief Interval for setting present to true.
+ *
+ * The amount of time to wait from not present to present change before
+ * updating the internal present indicator. Allows person servicing
+ * the power supply some time to plug in the cable.
+ */
+ std::chrono::seconds presentInterval;
+
+ /**
+ * @brief Timer used to delay setting the internal present state.
+ *
+ * The timer used to do the callback after the present property has
+ * changed.
+ */
+ Timer presentTimer;
+
/** @brief True if the power is on. */
bool powerOn = false;
@@ -105,9 +130,6 @@
*/
size_t powerOnFault = 0;
- /** @brief The sd_event structure used by the power on timer. */
- event::Event& event;
-
/**
* @brief Interval to setting powerOn to true.
*