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 thermal sensor issue #3020

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions platform/broadcom/platform-modules-accton.mk
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@ ACCTON_AS5835_54X_PLATFORM_MODULE = sonic-platform-accton-as5835-54x_$(ACCTON_AS
$(ACCTON_AS5835_54X_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as5835_54x-r0
$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_AS5835_54X_PLATFORM_MODULE)))


SONIC_STRETCH_DEBS += $(ACCTON_AS7712_32X_PLATFORM_MODULE)
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 @@ -122,8 +119,7 @@ def _get_thermal_val(self, thermal_num):
print "Error: unable to open file: %s" % str(e)
return 0
file_str = check_file.read()
search_str="average current temperature is"
print "file_str.find=%s"%file_str.find(search_str)
search_str="average current temperature is"
str_len = len(search_str)
idx=file_str.find(search_str)
if idx==-1:
Expand All @@ -139,7 +135,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 @@ -212,21 +212,16 @@ def manage_fans(self):
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
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 Expand Up @@ -337,4 +332,4 @@ def main(argv):

if __name__ == '__main__':
main(sys.argv[1:])


Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ Description: kernel modules for platform devices such as fan, led, sfp
Package: sonic-platform-accton-as5835-54x
Architecture: amd64
Description: kernel modules for platform devices such as fan, led, sfp

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ PACKAGE_PRE_NAME := sonic-platform-accton
KVERSION ?= $(shell uname -r)
KERNEL_SRC := /lib/modules/$(KVERSION)
MOD_SRC_DIR:= $(shell pwd)
MODULE_DIRS:= as7712-32x as5712-54x as7816-64x as7716-32x as7716-32xb as7312-54x as7326-56x as6712-32x as7726-32x as4630-54pe minipack as5812-54x as5835-54x
MODULE_DIRS:= as7712-32x as5712-54x as7816-64x as7716-32x as7716-32xb as7312-54x as7326-56x as6712-32x as7726-32x as4630-54pe minipack as5812-54x as5835-54x
MODULE_DIR := modules
UTILS_DIR := utils
SERVICE_DIR := service
Expand Down