2
0
mirror of https://opendev.org/x/pyghmi synced 2026-01-11 10:42:32 +00:00

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
This commit is contained in:
Jarrod Johnson
2023-04-17 11:24:06 -04:00
parent 537fccb8d7
commit 78cb1e9e1a

View File

@@ -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: