psusensor: Add support for the 'PowerState' parameter
When CPU is powered off, some sensor reading values are expected
to go below low thresholds. To prevent unnecessary sensor readings
and redundant threshold event trigger in cases like that add support
for the 'PowerState' JSON configuration parameter similar to other
'dbus-sensors' apps.
Use 'checkThresholdsPowerDelay' function in a threshold check like
it is done in ADCSensor app. This is necessary as PSU data can drop
faster than a change in a power state is noticed.
Tested on the AMD EthanolX CRB with ISL68137:
When the PowerState is set to "On" and the platform is powered off,
no transactions are observed on the corresponding I2C bus.
When the PowerState is set to "Always" monitoring is always enabled
and I2C transactions are always observed regardless the platform
power state.
These commands were used to monitor transactions
on the I2C bus:
$ echo 1 > /sys/kernel/debug/tracing/tracing_on
$ echo 1 > /sys/kernel/debug/tracing/events/i2c/i2c_read/enable
$ cat /sys/kernel/debug/tracing/trace_pipe
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Change-Id: Ic7b36e48828adf4eb2f7714965a4a1df4eb5ac3e
diff --git a/include/PSUEvent.hpp b/include/PSUEvent.hpp
index e1f895a..0821d3f 100644
--- a/include/PSUEvent.hpp
+++ b/include/PSUEvent.hpp
@@ -16,6 +16,7 @@
#pragma once
+#include <Utils.hpp>
#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/streambuf.hpp>
@@ -33,8 +34,8 @@
PSUSubEvent(std::shared_ptr<sdbusplus::asio::dbus_interface> eventInterface,
const std::string& path,
std::shared_ptr<sdbusplus::asio::connection>& conn,
- boost::asio::io_service& io, const std::string& groupEventName,
- const std::string& eventName,
+ boost::asio::io_service& io, const PowerState& readState,
+ const std::string& groupEventName, const std::string& eventName,
std::shared_ptr<std::set<std::string>> asserts,
std::shared_ptr<std::set<std::string>> combineEvent,
std::shared_ptr<bool> state, const std::string& psuName,
@@ -54,8 +55,10 @@
std::string path;
std::string eventName;
+ PowerState readState;
boost::asio::deadline_timer waitTimer;
std::shared_ptr<boost::asio::streambuf> readBuf;
+ void restartRead();
void handleResponse(const boost::system::error_code& err);
void updateValue(const int& newValue);
void beep(const uint8_t& beepPriority);
@@ -79,6 +82,7 @@
sdbusplus::asio::object_server& objectSever,
std::shared_ptr<sdbusplus::asio::connection>& conn,
boost::asio::io_service& io, const std::string& psuName,
+ const PowerState& powerState,
boost::container::flat_map<std::string, std::vector<std::string>>&
eventPathList,
boost::container::flat_map<