diff options
author | Tom Joseph <tomjoseph@in.ibm.com> | 2018-01-25 01:55:20 +0530 |
---|---|---|
committer | Tom Joseph <tomjoseph@in.ibm.com> | 2018-01-31 09:44:39 +0000 |
commit | c6162fb649a850e129d760f59369c8adf46d070f (patch) | |
tree | 20cdc293461f87a449f0f8ed6f53dba4a75e4a63 /sensorhandler.cpp | |
parent | e29be41f1d014a55e93abd3e55ac23f158f5fa16 (diff) | |
download | phosphor-host-ipmid-c6162fb649a850e129d760f59369c8adf46d070f.tar.gz phosphor-host-ipmid-c6162fb649a850e129d760f59369c8adf46d070f.zip |
sensor: Modify the Get sensor reading command
a) Scanning is enabled for all sensors, otherwise ipmitool would
report the sensors as disabled.
b) Correct the error handling scenario which will occur when the
D-Bus object is not present or error occurs when reading the D-Bus
property.
Change-Id: I49535663a242305ab02a67f8f5998647cfee7eee
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Diffstat (limited to 'sensorhandler.cpp')
-rw-r--r-- | sensorhandler.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sensorhandler.cpp b/sensorhandler.cpp index 8877bb3..e6320be 100644 --- a/sensorhandler.cpp +++ b/sensorhandler.cpp @@ -489,6 +489,8 @@ ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd, sd_bus_message *reply = NULL; int reading = 0; char* assertion = NULL; + ipmi::sensor::GetSensorResponse getResponse {}; + static constexpr auto scanningEnabledBit = 6; printf("IPMI GET_SENSOR_READING [0x%02x]\n",reqptr->sennum); @@ -622,7 +624,7 @@ ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd, resp->value = static_cast<uint8_t>( (raw_value - sensor.scaledOffset) / sensor.coefficientM); - resp->operation = 1<<6; // scanning enabled + resp->operation = 1 << scanningEnabledBit; // scanning enabled resp->indication[0] = 0; // not a threshold sensor. ignore resp->indication[1] = 0; rc = IPMI_CC_OK; @@ -638,22 +640,23 @@ ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd, try { - auto getResponse = iter->second.getFunc(iter->second); + getResponse = iter->second.getFunc(iter->second); *data_len = getResponse.size(); memcpy(resp, getResponse.data(), *data_len); + resp->operation = 1 << scanningEnabledBit; 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; + *data_len = getResponse.size(); + memcpy(resp, getResponse.data(), *data_len); + return IPMI_CC_OK; } catch (const std::runtime_error& e) { - log<level::ERR>(e.what()); - return IPMI_CC_SENSOR_INVALID; + *data_len = getResponse.size(); + memcpy(resp, getResponse.data(), *data_len); + return IPMI_CC_OK; } } } |