From 78cb1e9e1aaaa402272c95fac03bd82ceead6234 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 17 Apr 2023 11:24:06 -0400 Subject: [PATCH] Handle non-numeric with 0 number format The spec declares that if reading type is not threshold and no thresholds declared, then '0' means the same as '3'. Change-Id: I1f02ad27af4f2dad286387ed6aa0bdbcc1475fcf --- pyghmi/ipmi/sdr.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyghmi/ipmi/sdr.py b/pyghmi/ipmi/sdr.py index 36b54435..aaf8f5e7 100644 --- a/pyghmi/ipmi/sdr.py +++ b/pyghmi/ipmi/sdr.py @@ -372,6 +372,7 @@ class SDREntry(object): # event only, compact and full are very similar # this function handles the common aspects of compact and full # offsets from spec, minus 6 + self.has_thresholds = False self.sensor_owner = entry[0] self.sensor_lun = entry[1] & 0x03 self.sensor_number = entry[2] @@ -383,6 +384,8 @@ class SDREntry(object): else: self.sensor_type_number = entry[7] self.reading_type = entry[8] # table 42-1 + if self.rectype == 1 and entry[6] & 0b00001100: + self.has_thresholds = True try: self.sensor_type = self.event_consts.sensor_type_codes[ self.sensor_type_number] @@ -487,7 +490,7 @@ class SDREntry(object): numeric = twos_complement(reading[0], 8) elif self.numeric_format == 1: numeric = ones_complement(reading[0], 8) - elif self.numeric_format == 0: + elif self.numeric_format == 0 and (self.has_thresholds or self.reading_type == 1): numeric = reading[0] discrete = True if numeric is not None: