diff options
Diffstat (limited to 'sensorhandler.cpp')
-rw-r--r-- | sensorhandler.cpp | 61 |
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 { |