summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2017-09-07 02:16:51 +0530
committerTom Joseph <tomjoseph@in.ibm.com>2017-09-14 19:24:34 +0530
commit14c154678b0a22825bfd5701db6031c3feab7ce7 (patch)
tree5e44e8e8491f478f38244b20272baafc07830308
parent40c35b1c830c8c903c0120b074a3b7bc631a9861 (diff)
downloadphosphor-host-ipmid-14c154678b0a22825bfd5701db6031c3feab7ce7.tar.gz
phosphor-host-ipmid-14c154678b0a22825bfd5701db6031c3feab7ce7.zip
sensor: Use getFunc to handle the get sensor reading
Change-Id: If0f3185e7ce1d300be20b58ee5004a58e35c222d Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
-rw-r--r--sensorhandler.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index 1aa5181..ca8ef53 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -663,9 +663,28 @@ ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
break;
}
default:
- *data_len=0;
- rc = IPMI_CC_SENSOR_INVALID;
- break;
+ {
+ const auto iter = sensors.find(reqptr->sennum);
+ if (iter == sensors.end())
+ {
+ return IPMI_CC_SENSOR_INVALID;
+ }
+
+ try
+ {
+ auto getResponse = iter->second.getFunc(iter->second);
+ *data_len = getResponse.size();
+ memcpy(resp, getResponse.data(), *data_len);
+ return IPMI_CC_OK;
+ }
+ catch (InternalFailure& e)
+ {
+ log<level::ERR>("Get sensor failed",
+ entry("SENSOR_NUM=%d", reqptr->sennum));
+ commit<InternalFailure>();
+ return IPMI_CC_SENSOR_INVALID;
+ }
+ }
}
reply = sd_bus_message_unref(reply);
OpenPOWER on IntegriCloud