summaryrefslogtreecommitdiffstats
path: root/tach_sensor.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'tach_sensor.hpp')
-rw-r--r--tach_sensor.hpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/tach_sensor.hpp b/tach_sensor.hpp
index 24ee453..b9ac9b3 100644
--- a/tach_sensor.hpp
+++ b/tach_sensor.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server.hpp>
#include "sensor_base.hpp"
@@ -21,10 +22,16 @@ class TachSensor : public Sensor
TachSensor& operator=(TachSensor&&) = delete;
~TachSensor() = default;
- TachSensor(sdbusplus::bus::bus& bus,
- const std::string& id,
- FanEnclosure& fanEnc) : Sensor(id, fanEnc),
- bus(bus)
+ TachSensor(
+ sdbusplus::bus::bus& bus,
+ const std::string& id,
+ FanEnclosure& fanEnc) :
+ Sensor(id, fanEnc),
+ bus(bus),
+ tachSignal(bus,
+ match(id).c_str(),
+ handleTachChangeSignal,
+ this)
{
// Nothing to do here
}
@@ -33,8 +40,25 @@ class TachSensor : public Sensor
private:
sdbusplus::bus::bus& bus;
+ sdbusplus::server::match::match tachSignal;
int64_t tach = 0;
+ static std::string match(std::string id)
+ {
+ return std::string("type='signal',"
+ "interface='org.freedesktop.DBus.Properties',"
+ "member='PropertiesChanged',"
+ "path='/xyz/openbmc_project/sensors/fan_tach/" +
+ id + "'");
+ }
+ // Tach signal callback handler
+ static int handleTachChangeSignal(sd_bus_message* msg,
+ void* data,
+ sd_bus_error* err);
+
+ void handleTachChange(sdbusplus::message::message& msg,
+ sd_bus_error* err);
+
};
} // namespace presence
OpenPOWER on IntegriCloud