Skip to content

Implement Get Sensor Reading Factors to convert the readings of non-linear sensors (linearization 70h-7Fh) #144

Description

@bertysentry

Where: org.metricshub.ipmi.core.coding.commands.sdr (new command), src/main/java/org/metricshub/ipmi/client/runner/GetSensorsRunner.java, src/main/java/org/metricshub/ipmi/core/coding/commands/sdr/record/FullSensorRecord.java.

What happens: For a Full Sensor record whose linearization is non-linear (byte 24 = 70h-7Fh, IPMI 2.0 Table 43-1), the M, B and exponent factors of the SDR hold at the nominal reading only. Converting an arbitrary raw reading needs the Get Sensor Reading Factors command (section 35.5, NetFn Sensor/Event, command 23h), which returns the factors valid for a given raw reading. The library does not implement it.

Since #143, such sensors fail safe: FullSensorRecord.hasAnalogReading() is false, calcFormula() returns NaN, and IpmiClient returns the sensor with its states but without reading (1.2.02 dropped the sensor altogether). The gap noted in #83 is therefore closed by not reporting a value, not by computing it.

Suggested implementation:

  • A GetSensorReadingFactors coder: request = sensor number, raw reading byte; response (Table 35-6) = next reading, M (10 bits, 2's complement), tolerance (6 bits), B (10 bits, 2's complement), accuracy (10 bits), accuracy exponent, R exponent, B exponent, in the same layout as bytes 25-30 of the Full Sensor record.
  • A conversion entry point on FullSensorRecord that takes the factors as arguments (the current calcFormula() uses the record's own), applying the record's linearization function (e^x, log, ...) on top of the returned linear factors.
  • GetSensorsRunner: for a Full record whose linearization is 70h-7Fh, call Get Sensor Reading Factors with the raw reading obtained from Get Sensor Reading, and convert with the returned factors. The thresholds of such a record would need the same treatment (one call per threshold byte) if they are to be reported.
  • hasAnalogReading() then stays false only for the data format 11b.

Evidence: by the specification. Neither test BMC (GIGABYTE, Lenovo IMM) has a non-linear sensor, so the implementation can only be verified with unit tests on crafted bytes; say so in the PR.

Related: #83 (closed by #143 with the fail-safe behaviour), #111 and #101 (other client API enhancements). Low priority: non-linear sensors are rare in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions