2
0
mirror of https://opendev.org/x/pyghmi synced 2025-02-28 16:21:08 +00:00

Support newer SMMv2 API for PSU

Newer SMM firmware supports 16 bit wide fields instead of 8,
use struct to unpack them to align with the 8-bit wide fields from
before.

Change-Id: I485fa1bc03eb1fd6eaf7f0e800ed2a46ae5ad1ed
This commit is contained in:
Jarrod Johnson 2021-01-05 16:16:03 -05:00
parent 7a2a016233
commit 52a4f281fe

View File

@ -86,11 +86,15 @@ def fpc_read_psu_fan(ipmicmd, number, sz):
def fpc_get_psustatus(ipmicmd, number, sz):
rsp = ipmicmd.xraw_command(netfn=0x32, command=0x91)
mask = 1 << (number - 1)
rsp['data'] = bytearray(rsp['data'])
if len(rsp['data']) == 10:
tmpdata = rsp['data']
rsp['data'] = list(struct.unpack('<HHHHBB', tmpdata))
if len(rsp['data']) == 6:
statdata = bytearray([0])
statdata = [0]
else:
statdata = bytearray()
statdata += bytearray(rsp['data'])
statdata = []
statdata += rsp['data']
presence = statdata[3] & mask == mask
pwrgood = statdata[4] & mask == mask
throttle = (statdata[6] | statdata[2]) & mask == mask