Skip to content
Closed
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e0870a7
Add support as9716 platform
jostar-yang Jun 12, 2019
b580e8a
Merge branch 'master' of https://github.com/jostar-yang/sonic-buildimage
jostar-yang Jun 12, 2019
7973485
remove as9716
jostar-yang Jun 12, 2019
78f4fc3
remove as9716 needed mk
jostar-yang Jun 12, 2019
8a6c679
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Jun 17, 2019
f7826e3
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Jun 20, 2019
94006a5
Add to support as9716 platform
jostar-yang Jul 17, 2019
a893a68
Add support build as9716 platform to mk file
jostar-yang Jul 17, 2019
4c21d0a
Add support AS5835_54T platform
jostar-yang Jul 17, 2019
f3220df
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Jul 19, 2019
2e2b8ac
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Aug 5, 2019
c517556
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Sep 5, 2019
5ded80f
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Sep 11, 2019
e9aba06
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Sep 25, 2019
c148f54
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Oct 25, 2019
fa793e0
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Jan 6, 2020
48a537c
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Jan 7, 2020
531f583
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Mar 5, 2020
9002b0f
Merge remote-tracking branch 'upstream/master'
Apr 8, 2021
2854cdd
[as5835-54x] Fix read thermal sensor issue
Feb 17, 2021
edcfca8
[as5835-54x] Fix LGTM alert
Feb 17, 2021
6fa19bb
Fix control file error issue
Apr 9, 2021
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 @@ -22,7 +22,6 @@
# ------------------------------------------------------------------

try:
import os
import time
import logging
import glob
Expand All @@ -34,7 +33,7 @@
class ThermalUtil(object):
"""Platform-specific ThermalUtil class"""
THERMAL_NUM_MAX = 4
THERMAL_NUM_1_IDX = 1 # 1_ON_CPU_BROAD. LM75
THERMAL_NUM_1_IDX = 1 # 1_ON_CPU_BROAD. LM75
THERMAL_NUM_2_IDX = 2 # 2_ON_MAIN_BROAD. LM75
THERMAL_NUM_3_IDX = 3 # 3_ON_MAIN_BROAD. LM75
THERMAL_NUM_4_IDX = 4 # 4_ON_MAIN_BROAD. LM75
Expand All @@ -51,40 +50,37 @@ class ThermalUtil(object):
THERMAL_NUM_4_IDX: ['21', '4a'],
}
thermal_sysfspath ={
THERMAL_NUM_1_IDX: ["/sys/bus/i2c/devices/18-004b/hwmon/hwmon3/temp1_input"],
THERMAL_NUM_2_IDX: ["/sys/bus/i2c/devices/19-004c/hwmon/hwmon4/temp1_input"],
THERMAL_NUM_3_IDX: ["/sys/bus/i2c/devices/20-0049/hwmon/hwmon5/temp1_input"],
THERMAL_NUM_4_IDX: ["/sys/bus/i2c/devices/21-004a/hwmon/hwmon6/temp1_input"],
THERMAL_NUM_1_IDX: ["/sys/bus/i2c/devices/18-004b/hwmon/hwmon*/temp1_input"],
THERMAL_NUM_2_IDX: ["/sys/bus/i2c/devices/19-004c/hwmon/hwmon*/temp1_input"],
THERMAL_NUM_3_IDX: ["/sys/bus/i2c/devices/20-0049/hwmon/hwmon*/temp1_input"],
THERMAL_NUM_4_IDX: ["/sys/bus/i2c/devices/21-004a/hwmon/hwmon*/temp1_input"],
}

#def __init__(self):
def _get_thermal_val(self, thermal_num):
if thermal_num < self.THERMAL_NUM_1_IDX or thermal_num > self.THERMAL_NUM_MAX:
logging.debug('GET. Parameter error. thermal_num, %d', thermal_num)
return None

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

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()
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

return 0

def get_num_thermals(self):
return self.THERMAL_NUM_MAX
Expand Down Expand Up @@ -115,15 +111,11 @@ def get_thermal_temp(self):

def main():
thermal = ThermalUtil()
print "termal1=%d" %thermal._get_thermal_val(1)
print "termal2=%d" %thermal._get_thermal_val(2)
print "termal3=%d" %thermal._get_thermal_val(3)
print "termal4=%d" %thermal._get_thermal_val(4)
#
# print 'get_size_node_map : %d' % thermal.get_size_node_map()
# print 'get_size_path_map : %d' % thermal.get_size_path_map()
# for x in range(thermal.get_idx_thermal_start(), thermal.get_num_thermals()+1):
# print thermal.get_thermal_to_device_path(x)
#
logging.basicConfig(level=logging.DEBUG)
logging.debug('thermal1=%d', thermal._get_thermal_val(1))
logging.debug('thermal2=%d', thermal._get_thermal_val(2))
logging.debug('thermal3=%d', thermal._get_thermal_val(3))
logging.debug('thermal4=%d', thermal._get_thermal_val(4))

if __name__ == '__main__':
main()
main()