From e98d146addcab8a25037f927673c0616cde7d962 Mon Sep 17 00:00:00 2001 From: Nagaraju Goruganti Date: Tue, 8 May 2018 06:42:57 -0500 Subject: Fix Sensor query for derating factor returns 0 The issue here is that for derating factor sensor read command, hostboot is expecting return value in event_status field, but we are sending it in sensor reading field. Testing: ipmitool raw 0x04 0x2d 0xd8 #it has to retrun "00 00 5a 00" Resolves openbmc/openbmc#3012 Change-Id: I09e3d02c946ad1d8a39ea747fc400fb623cbe6ef Signed-off-by: Nagaraju Goruganti --- sensorhandler.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/sensorhandler.cpp b/sensorhandler.cpp index 1feef5b..ee62e17 100644 --- a/sensorhandler.cpp +++ b/sensorhandler.cpp @@ -460,7 +460,6 @@ ipmi_ret_t legacyGetSensorReading(uint8_t sensorNum, switch(type) { case 0xC2: - case 0xC8: r = sd_bus_get_property(bus,a.bus, a.path, a.interface, "value", NULL, &reply, "i"); if (r < 0) @@ -488,6 +487,34 @@ ipmi_ret_t legacyGetSensorReading(uint8_t sensorNum, resp->indication[1] = 0; break; + case 0xC8: + r = sd_bus_get_property(bus,a.bus, a.path, a.interface, + "value", NULL, &reply, "i"); + if (r < 0) + { + sd_journal_print(LOG_ERR, "Failed to call sd_bus_get_property:" + " %d, %s\n", r, strerror(-r)); + sd_journal_print(LOG_ERR, "Bus: %s, Path: %s, Interface: %s\n", + a.bus, a.path, a.interface); + break; + } + + r = sd_bus_message_read(reply, "i", &reading); + if (r < 0) { + sd_journal_print(LOG_ERR, "Failed to read sensor: %s\n", + strerror(-r)); + break; + } + + rc = IPMI_CC_OK; + *data_len=sizeof(sensorreadingresp_t); + + resp->value = 0; + resp->operation = 0; + resp->indication[0] = (uint8_t)reading; + resp->indication[1] = 0; + break; + //TODO openbmc/openbmc#2154 Move this sensor to right place. case 0xCA: r = sd_bus_get_property(bus,a.bus, a.path, a.interface, "value", -- cgit v1.2.1