summaryrefslogtreecommitdiffstats
path: root/sensorhandler.hpp
diff options
context:
space:
mode:
authorSui Chen <suichen@google.com>2019-09-11 10:28:35 -0700
committerVernon Mauery <vernon.mauery@linux.intel.com>2019-10-28 15:49:14 +0000
commit4cc42556be1e69f1210e3a0a0bcff49078e39ec6 (patch)
tree6da7fa0148f67a4cd863dbaf8d6a04b4c3871121 /sensorhandler.hpp
parent4c3feba5ad044190c4d3b7898e02d8a1a4b42f39 (diff)
downloadphosphor-host-ipmid-4cc42556be1e69f1210e3a0a0bcff49078e39ec6.tar.gz
phosphor-host-ipmid-4cc42556be1e69f1210e3a0a0bcff49078e39ec6.zip
Refactor ipmi::sensor::GetSensorResponse away from std::array
This change refactors GetSensorResponse from std::array to struct. This change depends on change #23544. GetSensorResponse is an internal, intermediate structure, an unpacked form of a Get Sensor Reading response, providing direct access to its fields. Its life time is: GetReadingResponse -> GetSensorResponse -> ipmi::RspType. It is written to in 5 functions in the ipmi::sensor::get namespace, by four setter functions (setOffset, setReading, setAssertionBytes, enableScanning). It is currently read from by 1 function (ipmiSensorGetSensorReading) for transforming to an ipmi::RspType. Originally, the setter functions assumed bitwise equivalence between GetSensorResponse and GetReadingResponse, and the setter functions used reinterpret_cast to assign to a GetSensorResponse as if it were a GetReadingResponse. With this change, the reinterpret_cast's are removed, and the set functions now accept GetSensorResponse instead of GetReadingResponse, so the code gets a bit easier to read. Tested: Tested using a server with a BMC; sensor readings obtained through `ipmitool` appear to be correct (the reading might change within a small range): # ipmitool raw 0x04 0x2d 0x16 9B 40 00 00 Signed-off-by: Sui Chen <suichen@google.com> Change-Id: I5d454d6249f5431fb98169e6ef7c585c34024004
Diffstat (limited to 'sensorhandler.hpp')
-rw-r--r--sensorhandler.hpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/sensorhandler.hpp b/sensorhandler.hpp
index f5a8b41..8780235 100644
--- a/sensorhandler.hpp
+++ b/sensorhandler.hpp
@@ -644,15 +644,15 @@ namespace sensor
* @param[in] offset - offset number.
* @param[in/out] resp - get sensor reading response.
*/
-inline void setOffset(uint8_t offset, ipmi::sensor::GetReadingResponse* resp)
+inline void setOffset(uint8_t offset, ipmi::sensor::GetSensorResponse* resp)
{
if (offset > 7)
{
- resp->assertOffset8_14 |= 1 << (offset - 8);
+ resp->discreteReadingSensorStates |= 1 << (offset - 8);
}
else
{
- resp->assertOffset0_7 |= 1 << offset;
+ resp->thresholdLevelsStates |= 1 << offset;
}
}
@@ -662,7 +662,7 @@ inline void setOffset(uint8_t offset, ipmi::sensor::GetReadingResponse* resp)
* @param[in] offset - offset number.
* @param[in/out] resp - get sensor reading response.
*/
-inline void setReading(uint8_t value, ipmi::sensor::GetReadingResponse* resp)
+inline void setReading(uint8_t value, ipmi::sensor::GetSensorResponse* resp)
{
resp->reading = value;
}
@@ -675,10 +675,10 @@ inline void setReading(uint8_t value, ipmi::sensor::GetReadingResponse* resp)
* @param[in/out] resp - get sensor reading response.
*/
inline void setAssertionBytes(uint16_t value,
- ipmi::sensor::GetReadingResponse* resp)
+ ipmi::sensor::GetSensorResponse* resp)
{
- resp->assertOffset0_7 = static_cast<uint8_t>(value & 0x00FF);
- resp->assertOffset8_14 = static_cast<uint8_t>(value >> 8);
+ resp->thresholdLevelsStates = static_cast<uint8_t>(value & 0x00FF);
+ resp->discreteReadingSensorStates = static_cast<uint8_t>(value >> 8);
}
/**
@@ -686,9 +686,11 @@ inline void setAssertionBytes(uint16_t value,
*
* @param[in/out] resp - get sensor reading response.
*/
-inline void enableScanning(ipmi::sensor::GetReadingResponse* resp)
+inline void enableScanning(ipmi::sensor::GetSensorResponse* resp)
{
- resp->operation = 1 << 6;
+ resp->readingOrStateUnavailable = false;
+ resp->scanningEnabled = true;
+ resp->allEventMessagesEnabled = false;
}
} // namespace sensor
OpenPOWER on IntegriCloud