Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix read lm75 thermal sensors issue #3285

Merged
merged 15 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ class ThermalUtil(object):
THERMAL_NUM_4_IDX: ['15', '4b'],
}
thermal_sysfspath ={
THERMAL_NUM_1_IDX: ["/sys/bus/i2c/drivers/lm75/15-0048/hwmon/hwmon2/temp1_input"],
THERMAL_NUM_2_IDX: ["/sys/bus/i2c/drivers/lm75/15-0049/hwmon/hwmon3/temp1_input"],
THERMAL_NUM_3_IDX: ["/sys/bus/i2c/drivers/lm75/15-004a/hwmon/hwmon4/temp1_input"],
THERMAL_NUM_4_IDX: ["/sys/bus/i2c/drivers/lm75/15-004b/hwmon/hwmon5/temp1_input"],
THERMAL_NUM_1_IDX: ["/sys/bus/i2c/drivers/lm75/15-0048/hwmon/hwmon*/temp1_input"],
THERMAL_NUM_2_IDX: ["/sys/bus/i2c/drivers/lm75/15-0049/hwmon/hwmon*/temp1_input"],
THERMAL_NUM_3_IDX: ["/sys/bus/i2c/drivers/lm75/15-004a/hwmon/hwmon*/temp1_input"],
THERMAL_NUM_4_IDX: ["/sys/bus/i2c/drivers/lm75/15-004b/hwmon/hwmon*/temp1_input"],
THERMAL_NUM_5_IDX: ["/sys/class/hwmon/hwmon0/temp1_input"],
}

Expand All @@ -89,28 +89,25 @@ def _get_thermal_val(self, thermal_num):
return None

if thermal_num < self.THERMAL_NUM_6_IDX:
device_path = self.get_thermal_to_device_path(thermal_num)
if(os.path.isfile(device_path)):
for filename in glob.glob(device_path):
try:
val_file = open(filename, 'r')
except IOError as e:
logging.error('GET. unable to open file: %s', str(e))
return None
content = val_file.readline().rstrip()
if content == '':
logging.debug('GET. content is NULL. device_path:%s', device_path)
return None
try:
val_file.close()
except:
logging.debug('GET. unable to close file. device_path:%s', device_path)
return None
device_path = self.get_thermal_to_device_path(thermal_num)

for filename in glob.glob(device_path):
try:
val_file = open(filename, 'r')
except IOError as e:
logging.error('GET. unable to open file: %s', str(e))
return None

content = val_file.readline().rstrip()
if content == '':
logging.debug('GET. content is NULL. device_path:%s', device_path)
return None
try:
val_file.close()
except:
logging.debug('GET. unable to close file. device_path:%s', device_path)
return None
return int(content)

else:
print "No such device_path=%s"%device_path
return 0

else:
log_os_system(self.BCM_thermal_cmd,0)
Expand All @@ -123,11 +120,11 @@ def _get_thermal_val(self, thermal_num):
return 0
file_str = check_file.read()
search_str="average current temperature is"
print "file_str.find=%s"%file_str.find(search_str)
#print "file_str.find=%s"%file_str.find(search_str)
str_len = len(search_str)
idx=file_str.find(search_str)
if idx==-1:
print "bcm sdk is not ready ,retrun 0"
#print "bcm sdk is not ready ,retrun 0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to either remove all of these commented-out print statements, or convert them into logging.debug() or logging.verbose() messages?

return 0
else:
#print "file_str[idx]=%c"%file_str[idx+str_len+1]
Expand All @@ -139,7 +136,7 @@ def _get_thermal_val(self, thermal_num):
#print "file_str[idx]=%c"%file_str[idx+str_len+2+5]
#print "file_str[idx]=%c"%file_str[idx+str_len+2+6]
temp_str=file_str[idx+str_len+1] + file_str[idx+str_len+2] + file_str[idx+str_len+3]+file_str[idx+str_len+4] +file_str[idx+str_len+5]
print "bcm temp_str=%s"%temp_str
#print "bcm temp_str=%s"%temp_str
check_file.close()
return float(temp_str)*1000

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,22 +211,17 @@ def manage_fans(self):
else:
temp_get= (temp2 + temp4)/2 # Use (sensor_LM75_49 + Thermal sensor_LM75_CPU_4B) /2
ori_state=fan_policy_state
fan_policy_state=self.get_state_from_fan_policy(temp_get, fan_policy)
print "temp2=%d"%temp2
print "temp4=%d"%temp4
print "temp_get=%d"%temp_get
#print "temp4=%d"%temp4
#print "temp6=%d"%temp6
fan_policy_state=self.get_state_from_fan_policy(temp_get, fan_policy)
logging.debug('lm75_48=%d, lm75_49=%d, lm75_4a=%d, lm_4b=%d, cpu=%d, bcm=%d', temp1,temp2,temp3,temp4,temp5,temp6)
logging.debug('ori_state=%d, fan_policy_state=%d', ori_state, fan_policy_state)
new_pwm = fan_policy_state_pwm_tlb[fan_policy_state][0]
if fan_fail==0:
logging.debug('new_pwm=%d', new_pwm)
logging.debug('new_pwm=%d', new_pwm)

if fan_fail==0:
if new_pwm!=ori_pwm:
fan.set_fan_duty_cycle(new_pwm)
logging.info('Set fan speed from %d to %d', ori_pwm, new_pwm)
if new_pwm!=ori_pwm:
fan.set_fan_duty_cycle(new_pwm)
logging.info('Set fan speed from %d to %d', ori_pwm, new_pwm)

for i in range (fan.FAN_NUM_1_IDX, fan.FAN_NUM_ON_MAIN_BROAD+1):
if fan.get_fan_status(i)==0:
Expand Down