2
0
mirror of https://opendev.org/x/pyghmi synced 2025-02-10 07:44:02 +00:00

Migrate V2 and newer systems to new meters

New proprietary commands are going to be used with a bit more
capability.  For now, migrate existing DC energy over to new command

Change-Id: I30a003c4d45f4a0d591c80c55f1c267333f1123c
This commit is contained in:
Jarrod Johnson 2022-07-08 10:25:29 -04:00
parent 5f1ba6038f
commit b4e597ff83

View File

@ -27,6 +27,15 @@ class EnergyManager(object):
# We start with a 'find firmware instance' to test the water and
# get the handle (which has always been the same, but just in case
self.iana = bytearray(b'\x66\x4a\x00')
self._usefapm = False
try:
rsp = ipmicmd.xraw_command(netfn=0x3a, command=0x32, data=[4, 2, 0, 0, 0])
self.supportedmeters = ('DC Energy',)
self._usefapm = True
return
except pygexc.IpmiException:
pass
try:
rsp = ipmicmd.xraw_command(netfn=0x2e, command=0x82,
data=self.iana + b'\x00\x00\x01')
@ -47,6 +56,12 @@ class EnergyManager(object):
else:
self.supportedmeters = ('DC Energy',)
def get_fapm_energy(self, ipmicmd):
rsp = ipmicmd.xraw_command(netfn=0x3a, command=0x32, data=[4, 2, 0, 0, 0])
j, mj = struct.unpack('<IH', rsp['data'][2:8])
mj = mj + (j * 1000)
return float(mj / 1000000 / 3600)
def get_energy_precision(self, ipmicmd):
rsp = ipmicmd.xraw_command(
netfn=0x2e, command=0x81,
@ -67,6 +82,8 @@ class EnergyManager(object):
raise
def get_dc_energy(self, ipmicmd):
if self._usefapm:
return self.get_fapm_energy(ipmicmd)
rsp = ipmicmd.xraw_command(
netfn=0x2e, command=0x81,
data=self.iana + self.modhandle + b'\x01\x82\x00\x08')