2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-27 19:37:44 +00:00

Fix for DIMM models with invalid bytes

Some DIMMs have short model numbers and pad with NULL.  Also tolerate
other common padding (0xff and spaces).

Change-Id: I01550996ade799b2c29d910ae9bb8c5150f94a38
This commit is contained in:
Jarrod Johnson 2017-10-11 09:22:41 -04:00
parent 19e3d74991
commit 9131df4ced

View File

@ -737,7 +737,8 @@ class SPD(object):
self.info['manufacture_date'] = decode_spd_date(spd[120], spd[121])
self.info['serial'] = hex(struct.unpack(
'>I', struct.pack('4B', *spd[122:126]))[0])[2:].rjust(8, '0')
self.info['model'] = struct.pack('18B', *spd[128:146])
self.info['model'] = struct.pack('18B', *spd[128:146]).strip(
'\x00\xff ')
def _decode_ddr4(self):
spd = self.rawdata
@ -762,4 +763,5 @@ class SPD(object):
self.info['manufacture_date'] = decode_spd_date(spd[323], spd[324])
self.info['serial'] = hex(struct.unpack(
'>I', struct.pack('4B', *spd[325:329]))[0])[2:].rjust(8, '0')
self.info['model'] = struct.pack('18B', *spd[329:347])
self.info['model'] = struct.pack('18B', *spd[329:347]).strip(
'\x00\xff ')