Skip to content

Commit

Permalink
cpusensor: change Min/Max values for power
Browse files Browse the repository at this point in the history
minValue and maxValue are currently hardcoded for all cpusensors to
-128 and 127 respectively. There is no sense to have negative values for
power sensors but CPU power consumption can be higher than 127W.
Change Min/Max to 0...511 for power sensors.

Tested: busctl introspect xyz.openbmc_project.CPUSensor /xyz/openbmc_project/sensors/power/Average_Power_CPU0
 xyz.openbmc_project.Sensor.Value interface --                                        -
 .MaxValue                        property  d 511                                      emits-change
 .MinValue                        property  d 0                                        emits-change
 .Unit                            property  s "xyz.openbmc_project.Sensor.Value.Unit.… emits-change
 .Value                           property  d 64.393                                   emits-change writable

Signed-off-by: Andrei Kartashev <a.kartashev@yadro.com>
Change-Id: I0dafdd657194b1b4d709ce093b658a89120f81f9
  • Loading branch information
Andrei Kartashev committed Dec 21, 2020
1 parent 937eb54 commit 6736d4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions include/CPUSensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class CPUSensor : public Sensor
static constexpr unsigned int sensorScaleFactor = 1000;
static constexpr unsigned int sensorPollMs = 1000;
static constexpr size_t warnAfterErrorCount = 10;
static constexpr double maxReading = 127;
static constexpr double minReading = -128;
static constexpr const char* labelTcontrol = "Tcontrol";

private:
Expand Down
8 changes: 6 additions & 2 deletions src/CPUSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ CPUSensor::CPUSensor(const std::string& path, const std::string& objectType,
const std::string& sensorConfiguration, int cpuId,
bool show, double dtsOffset) :
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(_thresholds), sensorConfiguration, objectType, maxReading,
minReading, conn, PowerState::on),
std::move(_thresholds), sensorConfiguration, objectType, 0, 0, conn,
PowerState::on),
objServer(objectServer), inputDev(io), waitTimer(io), path(path),
privTcontrol(std::numeric_limits<double>::quiet_NaN()),
dtsOffset(dtsOffset), show(show), pollTime(CPUSensor::sensorPollMs),
Expand All @@ -61,11 +61,15 @@ CPUSensor::CPUSensor(const std::string& path, const std::string& objectType,
if (type.compare("power") == 0)
{
interfacePath = "/xyz/openbmc_project/sensors/power/" + name;
minValue = 0;
maxValue = 511;
}
else
{
interfacePath =
"/xyz/openbmc_project/sensors/temperature/" + name;
minValue = -128;
maxValue = 127;
}

sensorInterface = objectServer.add_interface(
Expand Down

0 comments on commit 6736d4b

Please sign in to comment.