def GetBatteryProfile(self):
ret = self.interface.ReadData(self.BATTERY_PROFILE_CMD, 14)
if ret['error'] != 'NO_ERROR':
return ret
else:
d = ret['data']
if all(v == 0 for v in d):
return {'data':'INVALID', 'error':'NO_ERROR'}
profile = {}
profile['capacity'] = (d[1] << 8) | d[0]
profile['chargeCurrent'] = d[2] * 75 + 550
profile['terminationCurrent'] = d[3] * 50 + 50
profile['regulationVoltage'] = d[4] * 20 + 3500
profile['cutoffVoltage'] = d[5] * 20
profile['tempCold'] = ctypes.c_byte(d[6]).value
profile['tempCool'] = ctypes.c_byte(d[7]).value
profile['tempWarm'] = ctypes.c_byte(d[8]).value
profile['tempHot'] = ctypes.c_byte(d[9]).value
profile['ntcB'] = (d[11] << 8) | d[10]
profile['ntcResistance'] = ((d[13] << 8) | d[12]) * 10
return {'data':profile, 'error':'NO_ERROR'}
评论列表
文章目录