summaryrefslogtreecommitdiffstats
path: root/sensorhandler.cpp
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2018-02-16 09:37:43 +0530
committerTom Joseph <tomjoseph@in.ibm.com>2018-03-01 05:34:21 +0000
commit13b87a3ee204a79d5c31dfc0c3540fb207006833 (patch)
tree9fcf4f84c1aa56cf75e5d2f6634a7f792de28647 /sensorhandler.cpp
parent0ac0dd232627d9c44e53d41e2e6509a0471f013d (diff)
downloadphosphor-host-ipmid-13b87a3ee204a79d5c31dfc0c3540fb207006833.tar.gz
phosphor-host-ipmid-13b87a3ee204a79d5c31dfc0c3540fb207006833.zip
sensor: Refactor get sensor reading command
Use the functor in the generated yaml to get the sensor reading for analog sensors. Change-Id: I2535cd5015096c3e1e2baa5f9a865fc6b27e6875 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Diffstat (limited to 'sensorhandler.cpp')
-rw-r--r--sensorhandler.cpp61
1 files changed, 5 insertions, 56 deletions
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index e52ab69..f9294eb 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -523,9 +523,6 @@ ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
*data_len=0;
- int64_t raw_value;
- ipmi::sensor::Info sensor;
-
switch(type) {
case 0xC2:
case 0xC8:
@@ -586,59 +583,6 @@ ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
resp->indication[1] = 0;
break;
- case IPMI_SENSOR_TEMP:
- case IPMI_SENSOR_VOLTAGE:
- case IPMI_SENSOR_CURRENT:
- case IPMI_SENSOR_FAN:
- // Get reading for /xyz/openbmc_project/Sensor/Value.interface
- if(sensors.find(reqptr->sennum) == sensors.end())
- {
- fprintf(stderr, "Failed to find config entry for Sensor 0x%02x\n",
- reqptr->sennum);
- return IPMI_CC_SENSOR_INVALID;
- }
-
- sensor = sensors.at(reqptr->sennum);
- if (ipmi::sensor::Mutability::Read !=
- (sensor.mutability & ipmi::sensor::Mutability::Read))
- {
- log<level::ERR>("Sensor was not readable.\n");
- return IPMI_CC_SENSOR_INVALID;
- }
-
-
- // Get value
- r = sd_bus_get_property_trivial(bus,
- a.bus,
- a.path,
- a.interface,
- "Value",
- NULL,
- 'x',
- &raw_value);
- if (r < 0) {
- fprintf(stderr,
- "Failed to call sd_bus_get_property:%d, %s, 'value'\n",
- r,
- strerror(-r));
- fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n",
- a.bus, a.path, a.interface);
- break;
- }
-
- // Prevent div0
- if (sensor.coefficientM == 0) {
- sensor.coefficientM = 1;
- };
-
- resp->value = static_cast<uint8_t>(
- (raw_value - sensor.scaledOffset) / sensor.coefficientM);
- resp->operation = 1 << scanningEnabledBit; // scanning enabled
- resp->indication[0] = 0; // not a threshold sensor. ignore
- resp->indication[1] = 0;
- rc = IPMI_CC_OK;
- *data_len=sizeof(sensorreadingresp_t);
- break;
default:
{
const auto iter = sensors.find(reqptr->sennum);
@@ -646,6 +590,11 @@ ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
{
return IPMI_CC_SENSOR_INVALID;
}
+ if (ipmi::sensor::Mutability::Read !=
+ (iter->second.mutability & ipmi::sensor::Mutability::Read))
+ {
+ return IPMI_CC_SENSOR_INVALID;
+ }
try
{
OpenPOWER on IntegriCloud