From 7a3096e07bc68e9dae90feb517a96bd062a0865f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 6 Aug 2014 09:44:57 -0400 Subject: [PATCH] Force non-numeric for compact sensor records In the IPMI spec, compact sensors have the numeric format reserved and mandate an implementation set it to '3'. This mandate seems to have been ignored by some implementations. Force the value to be 3 for all compact sensor records and assume the reserved bits may never be used in a compact sensor. Change-Id: I88f5d7b533869809f213ab0c5379b276af50cd23 --- pyghmi/ipmi/sdr.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pyghmi/ipmi/sdr.py b/pyghmi/ipmi/sdr.py index 67b20376..9c7fa571 100644 --- a/pyghmi/ipmi/sdr.py +++ b/pyghmi/ipmi/sdr.py @@ -327,10 +327,19 @@ class SDREntry(object): # 1: generic threshold based # 0x6f: discrete sensor-specific from table 42-3, sensor offsets # all others per table 42-2, generic discrete - self.numeric_format = (entry[15] & 0b11000000) >> 6 - # the spec technically reserves numeric_format for compact sensor - # numeric, but common treatment won't break currently + # numeric format is one of: # 0 - unsigned, 1 - 1s complement, 2 - 2s complement, 3 - ignore number + # compact records are supposed to always write it as '3', presumably + # to allow for the concept of a compact record with a numeric format + # even though numerics are not allowed today. Some implementations + # violate the spec and do something other than 3 today. Tolerate + # the violation under the assumption that things are not so hard up + # that there will ever be a need for compact sensors supporting numeric + # values + if self.rectype == 2: + self.numeric_format = 3 + else: + self.numeric_format = (entry[15] & 0b11000000) >> 6 self.sensor_rate = sensor_rates[(entry[15] & 0b111000) >> 3] self.unit_mod = "" if (entry[15] & 0b110) == 0b10: # unit1 by unit2