dbus-sensors: PwmSensor math types cleanup

Cleaned up types during math to avoid precision loss.
Integer pwmMax and associated constants now double.
Avoid floating-point comparison, convert to int first.
Corrected rounding from float to int.
Property setter now ignores floating-point NaN.

Rounding done more consistently and correctly now. In some edge
cases, the fan PWM setting will be different from what it was
before, because rounding is now proper instead of truncating.

Tested: Swept fans from 0.0 to 100.0 percent, stepping by 0.1 each
time, to exercise all values between 0 and 255. Behavior now seems
more correct to me. Also set NaN, and it was properly ignored.
Also tested on the uint64_t interface, swept from 0 to 255,
each value mapped cleanly to equivalent floating-point value.

Not tested on "PSU" fans. These are a special case, as the integers
in the underlying file range from 0 to 100, not 0 to 255. The
original logic to handle these remains unchanged, however.

Signed-off-by: Josh Lehan <krellan@google.com>
Change-Id: Ibc9ad978c1567bb2e7116e00d84e43b4ae22e664
2 files changed
tree: c0d50f3f7641f2df30d12d7fea4eb8e4ee822d9c
  1. cmake/
  2. include/
  3. service_files/
  4. src/
  5. tests/
  6. .clang-format
  7. .clang-ignore
  8. .gitignore
  9. cmake-format.json
  10. CMakeLists.txt
  11. Jenkinsfile
  12. LICENSE
  13. MAINTAINERS
  14. README.md
README.md

dbus-sensors

dbus-sensors is a collection of sensor applications that provide the xyz.openbmc_project.Sensor collection of interfaces. They read sensor values from hwmon, d-bus, or direct driver access to provide readings. Some advance non-sensor features such as fan presence, pwm control, and automatic cpu detection (x86) are also supported.

key features

  • runtime re-configurable from d-bus (entity-manager or the like)

  • isolated: each sensor type is isolated into its own daemon, so a bug in one sensor is unlikely to affect another, and single sensor modifications are possible

  • async single-threaded: uses sdbusplus/asio bindings

  • multiple data inputs: hwmon, d-bus, direct driver access