summaryrefslogtreecommitdiffstats
path: root/sensorhandler.h
diff options
context:
space:
mode:
Diffstat (limited to 'sensorhandler.h')
-rw-r--r--sensorhandler.h51
1 files changed, 32 insertions, 19 deletions
diff --git a/sensorhandler.h b/sensorhandler.h
index 0b4c4e5..576c803 100644
--- a/sensorhandler.h
+++ b/sensorhandler.h
@@ -2,6 +2,7 @@
#define __HOST_IPMI_SEN_HANDLER_H__
#include <stdint.h>
+#include "types.hpp"
// IPMI commands for net functions.
enum ipmi_netfn_sen_cmds
@@ -39,25 +40,6 @@ int set_sensor_dbus_state_y(uint8_t , const char *, const uint8_t);
int find_openbmc_path(uint8_t , dbus_interface_t *);
/**
- * @struct SetSensorReadingReq
- *
- * IPMI Request data for Set Sensor Reading and Event Status Command
- */
-struct SetSensorReadingReq
-{
- uint8_t number;
- uint8_t operation;
- uint8_t reading;
- uint8_t assertOffset0_7;
- uint8_t assertOffset8_14;
- uint8_t deassertOffset0_7;
- uint8_t deassertOffset8_14;
- uint8_t eventData1;
- uint8_t eventData2;
- uint8_t eventData3;
-} __attribute__((packed));
-
-/**
* Get SDR Info
*/
@@ -489,4 +471,35 @@ struct SensorDataFullRecord
} __attribute__((packed));
} // get_sdr
+
+namespace ipmi
+{
+
+namespace sensor
+{
+
+/**
+ * @brief Map offset to the corresponding bit in the assertion byte.
+ *
+ * The discrete sensors support upto 14 states. 0-7 offsets are stored in one
+ * byte and offsets 8-14 in the second byte.
+ *
+ * @param[in] offset - offset number.
+ * @param[in/out] resp - get sensor reading response.
+ */
+inline void setOffset(uint8_t offset, ipmi::sensor::GetReadingResponse* resp)
+{
+ if (offset > 7)
+ {
+ resp->assertOffset8_14 |= 1 << (offset - 8);
+ }
+ else
+ {
+ resp->assertOffset0_7 |= 1 << offset;
+ }
+}
+
+} // namespace sensor
+
+} // namespace ipmi
#endif
OpenPOWER on IntegriCloud