[devices]: Add support as7326 thermal plan. Monitor fan/psu (#2344)
* Add support as7326 thermal plan. Monitor fan/psu * Fix incorrect kernel version for idt init * fix error parsing
This commit is contained in:
parent
8a4e779ce1
commit
7a74ff0c01
@ -18,9 +18,9 @@
|
|||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# HISTORY:
|
# HISTORY:
|
||||||
# mm/dd/yyyy (A.D.)
|
# mm/dd/yyyy (A.D.)
|
||||||
# 11/13/2017: Polly Hsu, Create
|
# 3/23/2018: Roy Lee modify for as7326_56x
|
||||||
# 1/10/2018: Jostar modify for as7716_32
|
# 6/26/2018: Jostar implement by new thermal policy from HW RD
|
||||||
# 3/32/2018: Roy Lee modify for as7326_56x
|
# ------------------------------------------------------------------
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -44,7 +44,6 @@ class FanUtil(object):
|
|||||||
|
|
||||||
FAN_NODE_NUM_OF_MAP = 2
|
FAN_NODE_NUM_OF_MAP = 2
|
||||||
FAN_NODE_FAULT_IDX_OF_MAP = 1
|
FAN_NODE_FAULT_IDX_OF_MAP = 1
|
||||||
#FAN_NODE_SPEED_IDX_OF_MAP = 2
|
|
||||||
FAN_NODE_DIR_IDX_OF_MAP = 2
|
FAN_NODE_DIR_IDX_OF_MAP = 2
|
||||||
#FAN_NODE_DUTY_IDX_OF_MAP = 4
|
#FAN_NODE_DUTY_IDX_OF_MAP = 4
|
||||||
#FANR_NODE_FAULT_IDX_OF_MAP = 5
|
#FANR_NODE_FAULT_IDX_OF_MAP = 5
|
||||||
@ -215,7 +214,6 @@ class FanUtil(object):
|
|||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print "Error: unable to open file: %s" % str(e)
|
||||||
return False
|
return False
|
||||||
#val = ((val + 1 ) * 625 +75 ) / 100
|
|
||||||
fan_file.write(str(val))
|
fan_file.write(str(val))
|
||||||
fan_file.close()
|
fan_file.close()
|
||||||
return True
|
return True
|
||||||
@ -232,7 +230,7 @@ class FanUtil(object):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if self.get_fan_fault(fan_num) is not None and self.get_fan_fault(fan_num) > 0:
|
if self.get_fan_fault(fan_num) is not None and self.get_fan_fault(fan_num) > 0:
|
||||||
logging.debug('GET. FAN fault. fan_num, %d', fan_num)
|
#logging.debug('GET. FAN fault. fan_num, %d', fan_num)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#if self.get_fanr_fault(fan_num) is not None and self.get_fanr_fault(fan_num) > 0:
|
#if self.get_fanr_fault(fan_num) is not None and self.get_fanr_fault(fan_num) > 0:
|
||||||
|
@ -18,79 +18,133 @@
|
|||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# HISTORY:
|
# HISTORY:
|
||||||
# mm/dd/yyyy (A.D.)
|
# mm/dd/yyyy (A.D.)
|
||||||
# 11/13/2017: Polly Hsu, Create
|
|
||||||
# 1/10/2018:Jostar modify for as7716_32x
|
|
||||||
# 3/23/2018: Roy Lee modify for as7326_56x
|
# 3/23/2018: Roy Lee modify for as7326_56x
|
||||||
|
# 6/26/2018: Jostar implement by new thermal policy from HW RD
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
import glob
|
import glob
|
||||||
|
import commands
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ImportError('%s - required module not found' % str(e))
|
raise ImportError('%s - required module not found' % str(e))
|
||||||
|
|
||||||
|
|
||||||
|
def log_os_system(cmd, show):
|
||||||
|
logging.info('Run :'+cmd)
|
||||||
|
status = 1
|
||||||
|
output = ""
|
||||||
|
status, output = commands.getstatusoutput(cmd)
|
||||||
|
if show:
|
||||||
|
print "ACC: " + str(cmd) + " , result:"+ str(status)
|
||||||
|
|
||||||
|
if status:
|
||||||
|
logging.info('Failed :'+cmd)
|
||||||
|
if show:
|
||||||
|
print('Failed :'+cmd)
|
||||||
|
return status, output
|
||||||
|
|
||||||
|
|
||||||
class ThermalUtil(object):
|
class ThermalUtil(object):
|
||||||
"""Platform-specific ThermalUtil class"""
|
"""Platform-specific ThermalUtil class"""
|
||||||
|
|
||||||
THERMAL_NUM_ON_MAIN_BROAD = 3
|
THERMAL_NUM_MAX = 6
|
||||||
THERMAL_NUM_1_IDX = 1 # 1_ON_MAIN_BROAD
|
THERMAL_NUM_1_IDX = 1 # 1_ON_MAIN_BROAD. LM75
|
||||||
THERMAL_NUM_2_IDX = 2 # 2_ON_MAIN_BROAD
|
THERMAL_NUM_2_IDX = 2 # 2_ON_MAIN_BROAD. LM75
|
||||||
THERMAL_NUM_3_IDX = 3 # 3_ON_MAIN_BROAD
|
THERMAL_NUM_3_IDX = 3 # 3_ON_MAIN_BROAD. LM75
|
||||||
|
THERMAL_NUM_4_IDX = 4 # CPU board. LM75
|
||||||
BASE_VAL_PATH = '/sys/bus/i2c/devices/{0}-00{1}/hwmon/hwmon*/temp1_input'
|
THERMAL_NUM_5_IDX = 5 # CPU core thermal
|
||||||
|
THERMAL_NUM_6_IDX = 6 # BCM thermal
|
||||||
|
|
||||||
|
BCM_thermal_cmd = 'bcmcmd "show temp" > /tmp/bcm_thermal'
|
||||||
|
BCM_thermal_path = '/tmp/bcm_thermal'
|
||||||
|
#BCM_thermal_path = '/tmp/bcm_debug'
|
||||||
""" Dictionary where
|
""" Dictionary where
|
||||||
key1 = thermal id index (integer) starting from 1
|
key1 = thermal id index (integer) starting from 1
|
||||||
value = path to fan device file (string) """
|
value = path to fan device file (string) """
|
||||||
_thermal_to_device_path_mapping = {}
|
#_thermal_to_device_path_mapping = {}
|
||||||
|
|
||||||
_thermal_to_device_node_mapping = {
|
_thermal_to_device_node_mapping = {
|
||||||
THERMAL_NUM_1_IDX: ['15', '48'],
|
THERMAL_NUM_1_IDX: ['15', '48'],
|
||||||
THERMAL_NUM_2_IDX: ['15', '49'],
|
THERMAL_NUM_2_IDX: ['15', '49'],
|
||||||
THERMAL_NUM_3_IDX: ['15', '4a'],
|
THERMAL_NUM_3_IDX: ['15', '4a'],
|
||||||
|
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_5_IDX: ["/sys/class/hwmon/hwmon0/temp1_input"],
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self):
|
#def __init__(self):
|
||||||
thermal_path = self.BASE_VAL_PATH
|
|
||||||
|
|
||||||
for x in range(self.THERMAL_NUM_1_IDX, self.THERMAL_NUM_ON_MAIN_BROAD+1):
|
def _get_thermal_val(self, thermal_num):
|
||||||
self._thermal_to_device_path_mapping[x] = thermal_path.format(
|
if thermal_num < self.THERMAL_NUM_1_IDX or thermal_num > self.THERMAL_NUM_MAX:
|
||||||
self._thermal_to_device_node_mapping[x][0],
|
|
||||||
self._thermal_to_device_node_mapping[x][1])
|
|
||||||
|
|
||||||
def _get_thermal_node_val(self, thermal_num):
|
|
||||||
if thermal_num < self.THERMAL_NUM_1_IDX or thermal_num > self.THERMAL_NUM_ON_MAIN_BROAD:
|
|
||||||
logging.debug('GET. Parameter error. thermal_num, %d', thermal_num)
|
logging.debug('GET. Parameter error. thermal_num, %d', thermal_num)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if thermal_num < self.THERMAL_NUM_6_IDX:
|
||||||
device_path = self.get_thermal_to_device_path(thermal_num)
|
device_path = self.get_thermal_to_device_path(thermal_num)
|
||||||
|
if(os.path.isfile(device_path)):
|
||||||
for filename in glob.glob(device_path):
|
for filename in glob.glob(device_path):
|
||||||
try:
|
try:
|
||||||
val_file = open(filename, 'r')
|
val_file = open(filename, 'r')
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
logging.error('GET. unable to open file: %s', str(e))
|
logging.error('GET. unable to open file: %s', str(e))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
content = val_file.readline().rstrip()
|
content = val_file.readline().rstrip()
|
||||||
|
|
||||||
if content == '':
|
if content == '':
|
||||||
logging.debug('GET. content is NULL. device_path:%s', device_path)
|
logging.debug('GET. content is NULL. device_path:%s', device_path)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
val_file.close()
|
val_file.close()
|
||||||
except:
|
except:
|
||||||
logging.debug('GET. unable to close file. device_path:%s', device_path)
|
logging.debug('GET. unable to close file. device_path:%s', device_path)
|
||||||
return None
|
return None
|
||||||
|
return int(content)
|
||||||
|
|
||||||
return int(content)
|
else:
|
||||||
|
print "No such device_path=%s"%device_path
|
||||||
|
return 0
|
||||||
|
|
||||||
|
else:
|
||||||
|
log_os_system(self.BCM_thermal_cmd,0)
|
||||||
|
file_path = self.BCM_thermal_path
|
||||||
|
check_file = open(file_path)
|
||||||
|
try:
|
||||||
|
check_file = open(file_path)
|
||||||
|
except IOError as e:
|
||||||
|
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)
|
||||||
|
str_len = len(search_str)
|
||||||
|
idx=file_str.find(search_str)
|
||||||
|
if idx==-1:
|
||||||
|
print "bcm sdk is not ready ,retrun 0"
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
#print "file_str[idx]=%c"%file_str[idx+str_len+1]
|
||||||
|
#print "file_str[idx]=%c"%file_str[idx+str_len+2]
|
||||||
|
#print "file_str[idx]=%c"%file_str[idx+str_len+2+1]
|
||||||
|
#print "file_str[idx]=%c"%file_str[idx+str_len+2+2]
|
||||||
|
#print "file_str[idx]=%c"%file_str[idx+str_len+2+3]
|
||||||
|
#print "file_str[idx]=%c"%file_str[idx+str_len+2+4]
|
||||||
|
#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
|
||||||
|
check_file.close()
|
||||||
|
return float(temp_str)*1000
|
||||||
|
|
||||||
def get_num_thermals(self):
|
def get_num_thermals(self):
|
||||||
return self.THERMAL_NUM_ON_MAIN_BROAD
|
return self.THERMAL_NUM_MAX
|
||||||
|
|
||||||
def get_idx_thermal_start(self):
|
def get_idx_thermal_start(self):
|
||||||
return self.THERMAL_NUM_1_IDX
|
return self.THERMAL_NUM_1_IDX
|
||||||
@ -99,10 +153,10 @@ class ThermalUtil(object):
|
|||||||
return len(self._thermal_to_device_node_mapping)
|
return len(self._thermal_to_device_node_mapping)
|
||||||
|
|
||||||
def get_size_path_map(self):
|
def get_size_path_map(self):
|
||||||
return len(self._thermal_to_device_path_mapping)
|
return len(self.thermal_sysfspath)
|
||||||
|
|
||||||
def get_thermal_to_device_path(self, thermal_num):
|
def get_thermal_to_device_path(self, thermal_num):
|
||||||
return self._thermal_to_device_path_mapping[thermal_num]
|
return self.thermal_sysfspath[thermal_num][0]
|
||||||
|
|
||||||
def get_thermal_1_val(self):
|
def get_thermal_1_val(self):
|
||||||
return self._get_thermal_node_val(self.THERMAL_NUM_1_IDX)
|
return self._get_thermal_node_val(self.THERMAL_NUM_1_IDX)
|
||||||
@ -112,13 +166,19 @@ class ThermalUtil(object):
|
|||||||
def get_thermal_temp(self):
|
def get_thermal_temp(self):
|
||||||
return (self._get_thermal_node_val(self.THERMAL_NUM_1_IDX) + self._get_thermal_node_val(self.THERMAL_NUM_2_IDX) +self._get_thermal_node_val(self.THERMAL_NUM_3_IDX))
|
return (self._get_thermal_node_val(self.THERMAL_NUM_1_IDX) + self._get_thermal_node_val(self.THERMAL_NUM_2_IDX) +self._get_thermal_node_val(self.THERMAL_NUM_3_IDX))
|
||||||
|
|
||||||
#def main():
|
def main():
|
||||||
# thermal = ThermalUtil()
|
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 "termal5=%d" %thermal._get_thermal_val(5)
|
||||||
|
print "termal6=%d" %thermal._get_thermal_val(6)
|
||||||
#
|
#
|
||||||
# print 'get_size_node_map : %d' % thermal.get_size_node_map()
|
# print 'get_size_node_map : %d' % thermal.get_size_node_map()
|
||||||
# print 'get_size_path_map : %d' % thermal.get_size_path_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):
|
# for x in range(thermal.get_idx_thermal_start(), thermal.get_num_thermals()+1):
|
||||||
# print thermal.get_thermal_to_device_path(x)
|
# print thermal.get_thermal_to_device_path(x)
|
||||||
#
|
#
|
||||||
#if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# main()
|
main()
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Accton AS7326-56X Platform MAC hnadle service
|
||||||
|
Before=pmon.service
|
||||||
|
After=sysinit.target
|
||||||
|
DefaultDependencies=no
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/local/bin/accton_handle_idt.sh
|
||||||
|
KillSignal=SIGKILL
|
||||||
|
SuccessExitStatus=SIGKILL
|
||||||
|
|
||||||
|
# Resource Limitations
|
||||||
|
LimitCORE=infinity
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@ -0,0 +1,16 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Accton AS7326-56X Platform Monitoring FAN service
|
||||||
|
Before=pmon.service
|
||||||
|
After=sysinit.target
|
||||||
|
DefaultDependencies=no
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/local/bin/accton_as7326_monitor_fan.py
|
||||||
|
KillSignal=SIGKILL
|
||||||
|
SuccessExitStatus=SIGKILL
|
||||||
|
|
||||||
|
# Resource Limitations
|
||||||
|
LimitCORE=infinity
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@ -0,0 +1,16 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Accton AS7326-56X Platform Monitoring PSU service
|
||||||
|
Before=pmon.service
|
||||||
|
After=sysinit.target
|
||||||
|
DefaultDependencies=no
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/local/bin/accton_as7326_monitor_psu.py
|
||||||
|
KillSignal=SIGKILL
|
||||||
|
SuccessExitStatus=SIGKILL
|
||||||
|
|
||||||
|
# Resource Limitations
|
||||||
|
LimitCORE=infinity
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@ -1,7 +1,7 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Accton AS7326-56X Platform Monitoring service
|
Description=Accton AS7326-56X Platform Monitoring service
|
||||||
Before=pmon.service
|
Before=pmon.service
|
||||||
After=sysinit.target
|
After=as7326-platform-handle_mac.service
|
||||||
DefaultDependencies=no
|
DefaultDependencies=no
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
@ -18,9 +18,8 @@
|
|||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# HISTORY:
|
# HISTORY:
|
||||||
# mm/dd/yyyy (A.D.)
|
# mm/dd/yyyy (A.D.)
|
||||||
# 11/13/2017: Polly Hsu, Create
|
|
||||||
# 1/10/2018: Jostar modify for as7716_32
|
|
||||||
# 3/23/2018: Roy Lee modify for as7326_56x
|
# 3/23/2018: Roy Lee modify for as7326_56x
|
||||||
|
# 6/26/2018: Jostar implement by new thermal policy from HW RD
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -31,6 +30,7 @@ try:
|
|||||||
import imp
|
import imp
|
||||||
import logging
|
import logging
|
||||||
import logging.config
|
import logging.config
|
||||||
|
import logging.handlers
|
||||||
import types
|
import types
|
||||||
import time # this is only being used as part of the example
|
import time # this is only being used as part of the example
|
||||||
import traceback
|
import traceback
|
||||||
@ -42,39 +42,63 @@ except ImportError as e:
|
|||||||
|
|
||||||
# Deafults
|
# Deafults
|
||||||
VERSION = '1.0'
|
VERSION = '1.0'
|
||||||
FUNCTION_NAME = 'accton_as7326_monitor'
|
FUNCTION_NAME = '/usr/local/bin/accton_as7326_monitor'
|
||||||
|
|
||||||
global log_file
|
global log_file
|
||||||
global log_level
|
global log_level
|
||||||
|
|
||||||
# (LM75_1+ LM75_2+ LM75_3) is LM75 at i2c addresses 0x48, 0x49, and 0x4A.
|
|
||||||
# TMP = (LM75_1+ LM75_2+ LM75_3)/3
|
|
||||||
#1. If TMP < 35, All fans run with duty 31.25%.
|
|
||||||
#2. If TMP>=35 or the temperature of any one of fan is higher than 40,
|
|
||||||
# All fans run with duty 50%
|
|
||||||
#3. If TMP >= 40 or the temperature of any one of fan is higher than 45,
|
|
||||||
# All fans run with duty 62.5%.
|
|
||||||
#4. If TMP >= 45 or the temperature of any one of fan is higher than 50,
|
|
||||||
# All fans run with duty 100%.
|
|
||||||
#5. Any one of 6 fans is fault, set duty = 100%.
|
|
||||||
#6. Direction factor. If it is B2F direction, duty + 12%.
|
|
||||||
|
|
||||||
# MISC:
|
|
||||||
# 1.Check single LM75 before applied average.
|
|
||||||
# 2.If no matched fan speed is found from the policy,
|
|
||||||
# use FAN_DUTY_CYCLE_MIN as default speed
|
|
||||||
# Get current temperature
|
|
||||||
# 4.Decision 3: Decide new fan speed depend on fan direction/current fan speed/temperature
|
|
||||||
|
|
||||||
|
#Default FAN speed: 37.5%(0x05)
|
||||||
|
#Ori is that detect: (U45_BCM56873 + Thermal sensor_LM75_CPU:0x4B) /2
|
||||||
|
#New Detect: (sensor_LM75_49 + Thermal sensor_LM75_CPU_4B) /2
|
||||||
|
#Thermal policy: Both F2B and B2F
|
||||||
|
#1. (sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 =< 39C , Keep 37.5%(0x05) Fan speed
|
||||||
|
#2. (sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 > 39C , Change Fan speed from 37.5%(0x05) to % 75%(0x0B)
|
||||||
|
#3. (sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 > 45C , Change Fan speed from 75%(0x0B) to 100%(0x0F)
|
||||||
|
#4. (sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 > 61C , Send alarm message
|
||||||
|
#5. (sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 > 66C , Shutdown system
|
||||||
|
#6. One Fan fail , Change Fan speed to 100%(0x0F)
|
||||||
|
|
||||||
|
#fan-dev 0-11 speed 0x05 Setup fan speed 37.50%
|
||||||
|
#fan-dev 0-11 speed 0xB Setup fan speed 75%
|
||||||
|
#fan-dev 0-11 speed 0xF Setup fan speed 100.00%
|
||||||
|
|
||||||
|
|
||||||
|
class switch(object):
|
||||||
|
def __init__(self, value):
|
||||||
|
self.value = value
|
||||||
|
self.fall = False
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
"""Return the match method once, then stop"""
|
||||||
|
yield self.match
|
||||||
|
raise StopIteration
|
||||||
|
|
||||||
|
def match(self, *args):
|
||||||
|
"""Indicate whether or not to enter a case suite"""
|
||||||
|
if self.fall or not args:
|
||||||
|
return True
|
||||||
|
elif self.value in args: # changed for v1.5, see below
|
||||||
|
self.fall = True
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
fan_policy_state=1
|
||||||
|
fan_fail=0
|
||||||
|
alarm_state = 0 #0->default or clear, 1-->alarm detect
|
||||||
|
test_temp = 0
|
||||||
|
test_temp_list = [0, 0, 0, 0, 0, 0]
|
||||||
|
|
||||||
# Make a class we can use to capture stdout and sterr in the log
|
# Make a class we can use to capture stdout and sterr in the log
|
||||||
class accton_as7326_monitor(object):
|
class device_monitor(object):
|
||||||
# static temp var
|
# static temp var
|
||||||
_ori_temp = 0
|
temp = 0
|
||||||
_new_perc = 0
|
new_pwm = 0
|
||||||
_ori_perc = 0
|
pwm=0
|
||||||
|
ori_pwm = 0
|
||||||
|
default_pwm=0x4
|
||||||
|
|
||||||
def __init__(self, log_file, log_level):
|
def __init__(self, log_file, log_level):
|
||||||
"""Needs a logger and a logger level."""
|
"""Needs a logger and a logger level."""
|
||||||
@ -86,7 +110,6 @@ class accton_as7326_monitor(object):
|
|||||||
format= '[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s',
|
format= '[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s',
|
||||||
datefmt='%H:%M:%S'
|
datefmt='%H:%M:%S'
|
||||||
)
|
)
|
||||||
|
|
||||||
# set up logging to console
|
# set up logging to console
|
||||||
if log_level == logging.DEBUG:
|
if log_level == logging.DEBUG:
|
||||||
console = logging.StreamHandler()
|
console = logging.StreamHandler()
|
||||||
@ -95,96 +118,189 @@ class accton_as7326_monitor(object):
|
|||||||
console.setFormatter(formatter)
|
console.setFormatter(formatter)
|
||||||
logging.getLogger('').addHandler(console)
|
logging.getLogger('').addHandler(console)
|
||||||
|
|
||||||
logging.debug('SET. logfile:%s / loglevel:%d', log_file, log_level)
|
sys_handler = handler = logging.handlers.SysLogHandler(address = '/dev/log')
|
||||||
|
sys_handler.setLevel(logging.WARNING)
|
||||||
|
logging.getLogger('').addHandler(sys_handler)
|
||||||
|
|
||||||
|
#logging.debug('SET. logfile:%s / loglevel:%d', log_file, log_level)
|
||||||
|
|
||||||
|
def get_state_from_fan_policy(self, temp, policy):
|
||||||
|
state=0
|
||||||
|
|
||||||
|
#if temp >= 75000:
|
||||||
|
# state=LEVEL_TEMP_CRITICAL
|
||||||
|
# return state
|
||||||
|
logging.debug('temp=%d', temp)
|
||||||
|
for i in range(0, len(policy)):
|
||||||
|
#logging.debug('policy[%d][0]=%d, policy[%d][1]=%d', i,policy[i][0],i, policy[i][1])
|
||||||
|
if temp > policy[i][0]:
|
||||||
|
if temp <= policy[i][1]:
|
||||||
|
state =policy[i][2]
|
||||||
|
logging.debug ('temp=%d >= policy[%d][0]=%d, temp=%d < policy[%d][1]=%d' , temp, i, policy[i][0], temp, i, policy[i][1])
|
||||||
|
logging.debug ('fan_state=%d', state)
|
||||||
|
if state==0:
|
||||||
|
state=policy[0][2] #below fan_min, set to default pwm
|
||||||
|
logging.debug('set default state')
|
||||||
|
return state
|
||||||
|
|
||||||
def manage_fans(self):
|
def manage_fans(self):
|
||||||
max_duty = 100
|
|
||||||
fan_policy_f2b = {
|
thermal_pwm_list = {} #Ori sort is lm75_48, 49, 4a, 4b, cpu, bcm
|
||||||
0: [32, 0, 105000],
|
# After get pwm, do sort to get max pwm.
|
||||||
1: [50, 105000, 120000],
|
LEVEL_FAN_DEF=1
|
||||||
2: [63, 120000, 135000],
|
LEVEL_FAN_MID=2
|
||||||
3: [max_duty, 135000, sys.maxsize],
|
LEVEL_FAN_MAX=3
|
||||||
|
LEVEL_TEMP_HIGH=4
|
||||||
|
LEVEL_TEMP_CRITICAL=5
|
||||||
|
|
||||||
|
fan_policy_state_pwm_tlb = {
|
||||||
|
LEVEL_FAN_DEF: [38, 0x4],
|
||||||
|
LEVEL_FAN_MID: [75, 0xB],
|
||||||
|
LEVEL_FAN_MAX: [100, 0xE],
|
||||||
|
LEVEL_TEMP_HIGH: [100, 0xE],
|
||||||
|
LEVEL_TEMP_CRITICAL: [100, 0xE],
|
||||||
}
|
}
|
||||||
fan_policy_b2f = {
|
global fan_policy_state
|
||||||
0: [44, 0, 105000],
|
global fan_fail
|
||||||
1: [63, 105000, 120000],
|
global test_temp
|
||||||
2: [75, 120000, 135000],
|
global test_temp_list
|
||||||
3: [max_duty, 135000, sys.maxsize],
|
global alarm_state
|
||||||
|
fan_policy ={
|
||||||
|
0: [0, 39000, LEVEL_FAN_DEF], #F2B_policy, B2F_plicy, PWM, reg_val
|
||||||
|
1: [39000, 45000, LEVEL_FAN_MID],
|
||||||
|
2: [45000, 61000, LEVEL_FAN_MAX],
|
||||||
|
3: [61000, 66000, LEVEL_TEMP_HIGH],
|
||||||
|
4: [66000, 200000, LEVEL_TEMP_CRITICAL],
|
||||||
}
|
}
|
||||||
fan_policy_single = {
|
|
||||||
0: 40000,
|
|
||||||
1: 45000,
|
|
||||||
2: 50000,
|
|
||||||
}
|
|
||||||
|
|
||||||
thermal = ThermalUtil()
|
thermal = ThermalUtil()
|
||||||
fan = FanUtil()
|
fan = FanUtil()
|
||||||
for x in range(fan.get_idx_fan_start(), fan.get_num_fans()+1):
|
fan_dir=fan.get_fan_dir(1)
|
||||||
fan_status = fan.get_fan_status(x)
|
if fan_dir > 1:
|
||||||
if fan_status is None:
|
fan_dri=1 #something wrong, set fan_dir to default val
|
||||||
logging.debug('INFO. SET new_perc to %d (FAN stauts is None. fan_num:%d)', max_duty, x)
|
if fan_dir < 0:
|
||||||
return False
|
fan_dri=1 #something wrong, set fan_dir to default val
|
||||||
if fan_status is False:
|
ori_pwm=fan.get_fan_duty_cycle()
|
||||||
logging.debug('INFO. SET new_perc to %d (FAN fault. fan_num:%d)', max_duty, x)
|
new_pwm=0
|
||||||
fan.set_fan_duty_cycle(max_duty)
|
logging.debug('fan_dir=%d, ori_pwm=%d', fan_dir, ori_pwm)
|
||||||
return True
|
logging.debug('test_temp=%d', test_temp)
|
||||||
#logging.debug('INFO. fan_status is True (fan_num:%d)', x)
|
if test_temp==0:
|
||||||
|
temp1 = thermal._get_thermal_val(1)
|
||||||
fan_dir=fan.get_fan_dir(1)
|
temp2 = thermal._get_thermal_val(2)
|
||||||
if fan_dir == 1:
|
temp3 = thermal._get_thermal_val(3)
|
||||||
fan_policy = fan_policy_f2b
|
temp4 = thermal._get_thermal_val(4)
|
||||||
|
temp5 = thermal._get_thermal_val(5)
|
||||||
|
#temp6 = thermal._get_thermal_val(6)
|
||||||
|
temp6=0
|
||||||
else:
|
else:
|
||||||
fan_policy = fan_policy_b2f
|
temp1 = test_temp_list[0]
|
||||||
|
temp2 = test_temp_list[1]
|
||||||
|
temp3 = test_temp_list[2]
|
||||||
|
temp4 = test_temp_list[3]
|
||||||
|
temp5 = test_temp_list[4]
|
||||||
|
#temp6 = test_temp_list[5]
|
||||||
|
temp6=0
|
||||||
|
fan_fail=0
|
||||||
|
|
||||||
#Decide fan duty by if any of sensors > fan_policy_single.
|
if temp2==0:
|
||||||
new_duty_cycle = fan_policy[0][0]
|
temp_get=50000 # if one detect sensor is fail or zero, assign temp=50000, let fan to 75%
|
||||||
for x in range(thermal.get_idx_thermal_start(), thermal.get_num_thermals()+1):
|
logging.debug('lm75_49 detect fail, so set temp_get=50000, let fan to 75%')
|
||||||
single_thm = thermal._get_thermal_node_val(x)
|
elif temp2==0:
|
||||||
for y in range(0, len(fan_policy_single)):
|
temp_get=50000 # if one detect sensor is fail or zero, assign temp=50000, let fan to 75%
|
||||||
if single_thm > fan_policy_single[y]:
|
logging.debug('lm75_4b detect fail, so set temp_get=50000, let fan to 75%')
|
||||||
if fan_policy[y+1][0] > new_duty_cycle:
|
else:
|
||||||
new_duty_cycle = fan_policy[y+1][0]
|
temp_get= (temp2 + temp4)/2 # Use (sensor_LM75_49 + Thermal sensor_LM75_CPU_4B) /2
|
||||||
logging.debug('INFO. Single thermal sensor %d with temp %d > %d , new_duty_cycle=%d',
|
ori_state=fan_policy_state
|
||||||
x, single_thm, fan_policy_single[y], new_duty_cycle)
|
fan_policy_state=self.get_state_from_fan_policy(temp_get, fan_policy)
|
||||||
single_result = new_duty_cycle
|
print "temp2=%d"%temp2
|
||||||
|
print "temp4=%d"%temp4
|
||||||
|
print "temp_get=%d"%temp_get
|
||||||
#Find if current duty matched any of define duty.
|
#print "temp4=%d"%temp4
|
||||||
#If not, set it to highest one.
|
#print "temp6=%d"%temp6
|
||||||
cur_duty_cycle = fan.get_fan_duty_cycle()
|
logging.debug('lm75_48=%d, lm75_49=%d, lm75_4a=%d, lm_4b=%d, cpu=%d, bcm=%d', temp1,temp2,temp3,temp4,temp5,temp6)
|
||||||
for x in range(0, len(fan_policy)):
|
logging.debug('ori_state=%d, fan_policy_state=%d', ori_state, fan_policy_state)
|
||||||
if cur_duty_cycle == fan_policy[x][0]:
|
new_pwm = fan_policy_state_pwm_tlb[fan_policy_state][0]
|
||||||
break
|
if fan_fail==0:
|
||||||
if x == len(fan_policy) :
|
logging.debug('new_pwm=%d', new_pwm)
|
||||||
fan.set_fan_duty_cycle(fan_policy[0][0])
|
|
||||||
cur_duty_cycle = max_duty
|
if fan_fail==0:
|
||||||
|
if new_pwm!=ori_pwm:
|
||||||
#Decide fan duty by if sum of sensors falls into any of fan_policy{}
|
fan.set_fan_duty_cycle(new_pwm)
|
||||||
get_temp = thermal.get_thermal_temp()
|
logging.info('Set fan speed from %d to %d', ori_pwm, new_pwm)
|
||||||
new_duty_cycle = cur_duty_cycle
|
|
||||||
for x in range(0, len(fan_policy)):
|
for i in range (fan.FAN_NUM_1_IDX, fan.FAN_NUM_ON_MAIN_BROAD+1):
|
||||||
y = len(fan_policy) - x -1 #checked from highest
|
if fan.get_fan_status(i)==0:
|
||||||
if get_temp > fan_policy[y][1] and get_temp < fan_policy[y][2] :
|
new_pwm=100
|
||||||
new_duty_cycle= fan_policy[y][0]
|
logging.debug('fan_%d fail, set pwm to 100',i)
|
||||||
logging.debug('INFO. Sum of temp %d > %d , new_duty_cycle=%d', get_temp, fan_policy[y][1], new_duty_cycle)
|
if test_temp==0:
|
||||||
|
fan_fail=1
|
||||||
sum_result = new_duty_cycle
|
fan.set_fan_duty_cycle(new_pwm)
|
||||||
if (sum_result>single_result):
|
break
|
||||||
new_duty_cycle = sum_result;
|
else:
|
||||||
else:
|
fan_fail=0
|
||||||
new_duty_cycle = single_result
|
|
||||||
|
#if fan_policy_state == ori_state:
|
||||||
logging.debug('INFO. Final duty_cycle=%d', new_duty_cycle)
|
# return True
|
||||||
if(new_duty_cycle != cur_duty_cycle):
|
#else:
|
||||||
fan.set_fan_duty_cycle(new_duty_cycle)
|
new_state = fan_policy_state
|
||||||
|
|
||||||
|
#logging.warning('Temperature high alarm testing')
|
||||||
|
if ori_state==LEVEL_FAN_DEF:
|
||||||
|
if new_state==LEVEL_TEMP_HIGH:
|
||||||
|
if alarm_state==0:
|
||||||
|
logging.warning('Alarm for temperature high is detected')
|
||||||
|
alarm_state=1
|
||||||
|
if new_state==LEVEL_TEMP_CRITICAL:
|
||||||
|
logging.critical('Alarm for temperature critical is detected, reboot DUT')
|
||||||
|
time.sleep(2)
|
||||||
|
os.system('reboot')
|
||||||
|
if ori_state==LEVEL_FAN_MID:
|
||||||
|
if new_state==LEVEL_TEMP_HIGH:
|
||||||
|
if alarm_state==0:
|
||||||
|
logging.warning('Alarm for temperature high is detected')
|
||||||
|
alarm_state=1
|
||||||
|
if new_state==LEVEL_TEMP_CRITICAL:
|
||||||
|
logging.critical('Alarm for temperature critical is detected')
|
||||||
|
time.sleep(2)
|
||||||
|
os.system('reboot')
|
||||||
|
if ori_state==LEVEL_FAN_MAX:
|
||||||
|
if new_state==LEVEL_TEMP_HIGH:
|
||||||
|
if alarm_state==0:
|
||||||
|
logging.warning('Alarm for temperature high is detected')
|
||||||
|
alarm_state=1
|
||||||
|
if new_state==LEVEL_TEMP_CRITICAL:
|
||||||
|
logging.critical('Alarm for temperature critical is detected')
|
||||||
|
time.sleep(2)
|
||||||
|
os.system('reboot')
|
||||||
|
if alarm_state==1:
|
||||||
|
if temp_get < (fan_policy[3][0] - 5000): #below 65 C, clear alarm
|
||||||
|
logging.warning('Alarm for temperature high is cleared')
|
||||||
|
alarm_state=0
|
||||||
|
if ori_state==LEVEL_TEMP_HIGH:
|
||||||
|
if new_state==LEVEL_TEMP_CRITICAL:
|
||||||
|
logging.critical('Alarm for temperature critical is detected')
|
||||||
|
time.sleep(2)
|
||||||
|
os.system('reboot')
|
||||||
|
if new_state <= LEVEL_FAN_MID:
|
||||||
|
logging.warning('Alarm for temperature high is cleared')
|
||||||
|
alarm_state=0
|
||||||
|
if new_state <= LEVEL_FAN_MAX:
|
||||||
|
if temp_get < (fan_policy[3][0] - 5000): #below 65 C, clear alarm
|
||||||
|
logging.warning('Alarm for temperature high is cleared')
|
||||||
|
alarm_state=0
|
||||||
|
if ori_state==LEVEL_TEMP_CRITICAL:
|
||||||
|
if new_state <= LEVEL_FAN_MAX:
|
||||||
|
logging.warning('Alarm for temperature critical is cleared')
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
log_file = '%s.log' % FUNCTION_NAME
|
log_file = '%s.log' % FUNCTION_NAME
|
||||||
log_level = logging.INFO
|
log_level = logging.INFO
|
||||||
|
global test_temp
|
||||||
if len(sys.argv) != 1:
|
if len(sys.argv) != 1:
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
opts, args = getopt.getopt(argv,'hdlt:',['lfile='])
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||||
return 0
|
return 0
|
||||||
@ -195,14 +311,30 @@ def main(argv):
|
|||||||
elif opt in ('-d', '--debug'):
|
elif opt in ('-d', '--debug'):
|
||||||
log_level = logging.DEBUG
|
log_level = logging.DEBUG
|
||||||
elif opt in ('-l', '--lfile'):
|
elif opt in ('-l', '--lfile'):
|
||||||
log_file = arg
|
log_file = arg
|
||||||
|
|
||||||
monitor = accton_as7326_monitor(log_file, log_level)
|
if sys.argv[1]== '-t':
|
||||||
|
if len(sys.argv)!=8:
|
||||||
|
print "temp test, need input six temp"
|
||||||
|
return 0
|
||||||
|
|
||||||
|
i=0
|
||||||
|
for x in range(2, 8):
|
||||||
|
test_temp_list[i]= int(sys.argv[x])*1000
|
||||||
|
i=i+1
|
||||||
|
test_temp = 1
|
||||||
|
log_level = logging.DEBUG
|
||||||
|
print test_temp_list
|
||||||
|
|
||||||
|
fan = FanUtil()
|
||||||
|
fan.set_fan_duty_cycle(38)
|
||||||
|
print "set default fan speed to 37.5%"
|
||||||
|
monitor = device_monitor(log_file, log_level)
|
||||||
# Loop forever, doing something useful hopefully:
|
# Loop forever, doing something useful hopefully:
|
||||||
while True:
|
while True:
|
||||||
monitor.manage_fans()
|
monitor.manage_fans()
|
||||||
time.sleep(10)
|
time.sleep(5)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
|
|
@ -0,0 +1,200 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Accton Technology Corporation
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# HISTORY:
|
||||||
|
# mm/dd/yyyy (A.D.)
|
||||||
|
# 7/2/2018: Jostar create for as7326-56x
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
try:
|
||||||
|
import os
|
||||||
|
import sys, getopt
|
||||||
|
import subprocess
|
||||||
|
import click
|
||||||
|
import imp
|
||||||
|
import logging
|
||||||
|
import logging.config
|
||||||
|
import logging.handlers
|
||||||
|
import types
|
||||||
|
import time # this is only being used as part of the example
|
||||||
|
import traceback
|
||||||
|
from tabulate import tabulate
|
||||||
|
|
||||||
|
except ImportError as e:
|
||||||
|
raise ImportError('%s - required module not found' % str(e))
|
||||||
|
|
||||||
|
# Deafults
|
||||||
|
VERSION = '1.0'
|
||||||
|
FUNCTION_NAME = '/usr/local/bin/accton_as7326_monitor_fan'
|
||||||
|
|
||||||
|
global log_file
|
||||||
|
global log_level
|
||||||
|
|
||||||
|
|
||||||
|
class switch(object):
|
||||||
|
def __init__(self, value):
|
||||||
|
self.value = value
|
||||||
|
self.fall = False
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
"""Return the match method once, then stop"""
|
||||||
|
yield self.match
|
||||||
|
raise StopIteration
|
||||||
|
|
||||||
|
def match(self, *args):
|
||||||
|
"""Indicate whether or not to enter a case suite"""
|
||||||
|
if self.fall or not args:
|
||||||
|
return True
|
||||||
|
elif self.value in args: # changed for v1.5, see below
|
||||||
|
self.fall = True
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
fan_state=[2, 2, 2, 2, 2, 2, 2] #init state=2, insert=1, remove=0
|
||||||
|
fan_status_state=[2, 2, 2, 2, 2, 2, 2] #init state=2, fault=1, normal=0
|
||||||
|
# Make a class we can use to capture stdout and sterr in the log
|
||||||
|
class device_monitor(object):
|
||||||
|
|
||||||
|
#/sys/bus/i2c/devices/11-0066
|
||||||
|
#fan1_present, fan6_present
|
||||||
|
|
||||||
|
def __init__(self, log_file, log_level):
|
||||||
|
|
||||||
|
self.fan_num = 6
|
||||||
|
self.fan_path = "/sys/bus/i2c/devices/11-0066/"
|
||||||
|
self.present = {
|
||||||
|
0: "fan1_present",
|
||||||
|
1: "fan2_present",
|
||||||
|
2: "fan3_present",
|
||||||
|
3: "fan4_present",
|
||||||
|
4: "fan5_present",
|
||||||
|
5: "fan6_present",
|
||||||
|
}
|
||||||
|
|
||||||
|
self.fault = {
|
||||||
|
0: "fan1_fault",
|
||||||
|
1: "fan2_fault",
|
||||||
|
2: "fan3_fault",
|
||||||
|
3: "fan4_fault",
|
||||||
|
4: "fan5_fault",
|
||||||
|
5: "fan6_fault",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
"""Needs a logger and a logger level."""
|
||||||
|
# set up logging to file
|
||||||
|
logging.basicConfig(
|
||||||
|
filename=log_file,
|
||||||
|
filemode='w',
|
||||||
|
level=log_level,
|
||||||
|
format= '[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s',
|
||||||
|
datefmt='%H:%M:%S'
|
||||||
|
)
|
||||||
|
|
||||||
|
# set up logging to console
|
||||||
|
if log_level == logging.DEBUG:
|
||||||
|
console = logging.StreamHandler()
|
||||||
|
console.setLevel(logging.DEBUG)
|
||||||
|
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
|
||||||
|
console.setFormatter(formatter)
|
||||||
|
logging.getLogger('').addHandler(console)
|
||||||
|
|
||||||
|
sys_handler = logging.handlers.SysLogHandler(address = '/dev/log')
|
||||||
|
#sys_handler.setLevel(logging.WARNING)
|
||||||
|
sys_handler.setLevel(logging.INFO)
|
||||||
|
logging.getLogger('').addHandler(sys_handler)
|
||||||
|
|
||||||
|
|
||||||
|
#logging.debug('SET. logfile:%s / loglevel:%d', log_file, log_level)
|
||||||
|
|
||||||
|
def manage_fan(self):
|
||||||
|
|
||||||
|
FAN_STATE_REMOVE = 0
|
||||||
|
FAN_STATE_INSERT = 1
|
||||||
|
|
||||||
|
FAN_STATUS_FAULT = 1
|
||||||
|
FAN_STATUS_NORMAL = 0
|
||||||
|
|
||||||
|
global fan_state
|
||||||
|
global fan_status_state
|
||||||
|
|
||||||
|
for idx in range (0, self.fan_num):
|
||||||
|
node = self.fan_path + self.present[idx]
|
||||||
|
try:
|
||||||
|
val_file = open(node)
|
||||||
|
except IOError as e:
|
||||||
|
print "Error: unable to open file: %s" % str(e)
|
||||||
|
return False
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
|
# content is a string, either "0" or "1"
|
||||||
|
if content == "1":
|
||||||
|
if fan_state[idx]!=1:
|
||||||
|
fan_state[idx]=FAN_STATE_INSERT
|
||||||
|
logging.info("FAN-%d present is detected", idx+1);
|
||||||
|
else:
|
||||||
|
if fan_state[idx]!=0:
|
||||||
|
fan_state[idx]=FAN_STATE_REMOVE
|
||||||
|
logging.warning("Alarm for FAN-%d absent is detected", idx+1)
|
||||||
|
|
||||||
|
for idx in range (0, self.fan_num):
|
||||||
|
node = self.fan_path + self.fault[idx]
|
||||||
|
try:
|
||||||
|
val_file = open(node)
|
||||||
|
except IOError as e:
|
||||||
|
print "Error: unable to open file: %s" % str(e)
|
||||||
|
return False
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
|
# content is a string, either "0" or "1"
|
||||||
|
if content == "1":
|
||||||
|
if fan_status_state[idx]!=FAN_STATUS_FAULT:
|
||||||
|
if fan_state[idx] == FAN_STATE_INSERT:
|
||||||
|
logging.warning("Alarm for FAN-%d failed is detected", idx+1);
|
||||||
|
fan_status_state[idx]=FAN_STATUS_FAULT
|
||||||
|
else:
|
||||||
|
fan_status_state[idx]=FAN_STATUS_NORMAL
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
log_file = '%s.log' % FUNCTION_NAME
|
||||||
|
log_level = logging.INFO
|
||||||
|
if len(sys.argv) != 1:
|
||||||
|
try:
|
||||||
|
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||||
|
except getopt.GetoptError:
|
||||||
|
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||||
|
return 0
|
||||||
|
for opt, arg in opts:
|
||||||
|
if opt == '-h':
|
||||||
|
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||||
|
return 0
|
||||||
|
elif opt in ('-d', '--debug'):
|
||||||
|
log_level = logging.DEBUG
|
||||||
|
elif opt in ('-l', '--lfile'):
|
||||||
|
log_file = arg
|
||||||
|
monitor = device_monitor(log_file, log_level)
|
||||||
|
while True:
|
||||||
|
monitor.manage_fan()
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main(sys.argv[1:])
|
@ -0,0 +1,190 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Accton Technology Corporation
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# HISTORY:
|
||||||
|
# mm/dd/yyyy (A.D.)
|
||||||
|
# 7/2/2018: Jostar create for as7326-56x
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
try:
|
||||||
|
import os
|
||||||
|
import sys, getopt
|
||||||
|
import subprocess
|
||||||
|
import click
|
||||||
|
import imp
|
||||||
|
import logging
|
||||||
|
import logging.config
|
||||||
|
import logging.handlers
|
||||||
|
import types
|
||||||
|
import time # this is only being used as part of the example
|
||||||
|
import traceback
|
||||||
|
from tabulate import tabulate
|
||||||
|
except ImportError as e:
|
||||||
|
raise ImportError('%s - required module not found' % str(e))
|
||||||
|
|
||||||
|
# Deafults
|
||||||
|
VERSION = '1.0'
|
||||||
|
FUNCTION_NAME = '/usr/local/bin/accton_as7326_monitor_psu'
|
||||||
|
|
||||||
|
global log_file
|
||||||
|
global log_level
|
||||||
|
|
||||||
|
|
||||||
|
class switch(object):
|
||||||
|
def __init__(self, value):
|
||||||
|
self.value = value
|
||||||
|
self.fall = False
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
"""Return the match method once, then stop"""
|
||||||
|
yield self.match
|
||||||
|
raise StopIteration
|
||||||
|
|
||||||
|
def match(self, *args):
|
||||||
|
"""Indicate whether or not to enter a case suite"""
|
||||||
|
if self.fall or not args:
|
||||||
|
return True
|
||||||
|
elif self.value in args: # changed for v1.5, see below
|
||||||
|
self.fall = True
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
psu_state=[2, 2]
|
||||||
|
psu_power_status=[2, 2]
|
||||||
|
# Make a class we can use to capture stdout and sterr in the log
|
||||||
|
class device_monitor(object):
|
||||||
|
|
||||||
|
def __init__(self, log_file, log_level):
|
||||||
|
|
||||||
|
self.psu_num = 2
|
||||||
|
self.psu_path = "/sys/bus/i2c/devices/"
|
||||||
|
self.presence = "/psu_present"
|
||||||
|
self.oper_status = "/psu_power_good"
|
||||||
|
self.mapping = {
|
||||||
|
0: "17-0051",
|
||||||
|
1: "13-0053",
|
||||||
|
}
|
||||||
|
|
||||||
|
"""Needs a logger and a logger level."""
|
||||||
|
# set up logging to file
|
||||||
|
logging.basicConfig(
|
||||||
|
filename=log_file,
|
||||||
|
filemode='w',
|
||||||
|
level=log_level,
|
||||||
|
format= '[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s',
|
||||||
|
datefmt='%H:%M:%S'
|
||||||
|
)
|
||||||
|
# set up logging to console
|
||||||
|
|
||||||
|
if log_level == logging.DEBUG:
|
||||||
|
console = logging.StreamHandler()
|
||||||
|
console.setLevel(log_level)
|
||||||
|
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
|
||||||
|
console.setFormatter(formatter)
|
||||||
|
logging.getLogger('').addHandler(console)
|
||||||
|
|
||||||
|
sys_handler = logging.handlers.SysLogHandler(address = '/dev/log')
|
||||||
|
#sys_handler.setLevel(logging.WARNING)
|
||||||
|
sys_handler.setLevel(logging.INFO)
|
||||||
|
logging.getLogger('').addHandler(sys_handler)
|
||||||
|
|
||||||
|
#logging.debug('SET. logfile:%s / loglevel:%d', log_file, log_level)
|
||||||
|
|
||||||
|
def manage_psu(self):
|
||||||
|
|
||||||
|
PSU_STATE_REMOVE = 0
|
||||||
|
PSU_STATE_INSERT = 1
|
||||||
|
|
||||||
|
PSU_STATUS_NO_POWER = 0
|
||||||
|
PSU_STATUS_POWER_GOOD = 1
|
||||||
|
|
||||||
|
global psu_state
|
||||||
|
global psu_power_status
|
||||||
|
|
||||||
|
for idx in range (0, self.psu_num):
|
||||||
|
node = self.psu_path + self.mapping[idx] + self.presence
|
||||||
|
try:
|
||||||
|
val_file = open(node)
|
||||||
|
except IOError as e:
|
||||||
|
print "Error: unable to open file: %s" % str(e)
|
||||||
|
return False
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
|
# content is a string, either "0" or "1"
|
||||||
|
if content == "1":
|
||||||
|
if psu_state[idx]!=PSU_STATE_INSERT:
|
||||||
|
psu_state[idx]=PSU_STATE_INSERT
|
||||||
|
logging.info("PSU-%d present is detected", idx+1);
|
||||||
|
#psu_power_status[idx]=PSU_STATUS_POWER_GOOD #when insert, assume power is good. If no_power, next code will find it.
|
||||||
|
else:
|
||||||
|
if psu_state[idx]!=PSU_STATE_REMOVE:
|
||||||
|
psu_state[idx]=PSU_STATE_REMOVE
|
||||||
|
logging.warning("Alarm for PSU-%d absent is detected", idx+1);
|
||||||
|
psu_power_status[idx]=PSU_STATUS_NO_POWER
|
||||||
|
|
||||||
|
for idx in range (0, self.psu_num):
|
||||||
|
node = self.psu_path + self.mapping[idx] + self.oper_status
|
||||||
|
try:
|
||||||
|
val_file = open(node)
|
||||||
|
except IOError as e:
|
||||||
|
print "Error: unable to open file: %s" % str(e)
|
||||||
|
return False
|
||||||
|
content = val_file.readline().rstrip()
|
||||||
|
val_file.close()
|
||||||
|
# content is a string, either "0" or "1"
|
||||||
|
#logging.info("content=%s, psu_power_status[%d]=%d", content, idx, psu_power_status[idx]);
|
||||||
|
if content == "0":
|
||||||
|
if psu_power_status[idx]!=PSU_STATUS_NO_POWER:
|
||||||
|
if psu_state[idx]==PSU_STATE_INSERT:
|
||||||
|
logging.warning("Alarm for PSU-%d fault is detected", idx+1);
|
||||||
|
psu_power_status[idx]=PSU_STATUS_NO_POWER
|
||||||
|
else:
|
||||||
|
if psu_power_status[idx] !=PSU_STATUS_POWER_GOOD:
|
||||||
|
logging.info("PSU-%d power_good is detected", idx+1);
|
||||||
|
psu_power_status[idx]=PSU_STATUS_POWER_GOOD
|
||||||
|
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
log_file = '%s.log' % FUNCTION_NAME
|
||||||
|
log_level = logging.INFO
|
||||||
|
if len(sys.argv) != 1:
|
||||||
|
try:
|
||||||
|
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||||
|
except getopt.GetoptError:
|
||||||
|
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||||
|
return 0
|
||||||
|
for opt, arg in opts:
|
||||||
|
if opt == '-h':
|
||||||
|
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||||
|
return 0
|
||||||
|
elif opt in ('-d', '--debug'):
|
||||||
|
log_level = logging.DEBUG
|
||||||
|
elif opt in ('-l', '--lfile'):
|
||||||
|
log_file = arg
|
||||||
|
monitor = device_monitor(log_file, log_level)
|
||||||
|
# Loop forever, doing something useful hopefully:
|
||||||
|
while True:
|
||||||
|
monitor.manage_psu()
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main(sys.argv[1:])
|
@ -175,6 +175,8 @@ kos = [
|
|||||||
|
|
||||||
def driver_install():
|
def driver_install():
|
||||||
global FORCE
|
global FORCE
|
||||||
|
|
||||||
|
status, output = log_os_system('modprobe i2c_dev', 1)
|
||||||
status, output = log_os_system("depmod", 1)
|
status, output = log_os_system("depmod", 1)
|
||||||
for i in range(0,len(kos)):
|
for i in range(0,len(kos)):
|
||||||
status, output = log_os_system(kos[i], 1)
|
status, output = log_os_system(kos[i], 1)
|
||||||
@ -215,8 +217,8 @@ i2c_nodes = {'fan': ['present', 'front_speed_rpm', 'rear_speed_rpm'] ,
|
|||||||
|
|
||||||
sfp_map = [
|
sfp_map = [
|
||||||
42,41,44,43,47,45,46,50,
|
42,41,44,43,47,45,46,50,
|
||||||
48,49,51,52,53,56,55,54,
|
48,49,52,51,53,56,55,54,
|
||||||
58,57,59,60,61,63,62,64,
|
58,57,60,59,61,63,62,64,
|
||||||
66,68,65,67,69,71,72,70,
|
66,68,65,67,69,71,72,70,
|
||||||
74,73,76,75,77,79,78,80,
|
74,73,76,75,77,79,78,80,
|
||||||
81,82,84,85,83,87,88,86, #port 41~48
|
81,82,84,85,83,87,88,86, #port 41~48
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -s /usr/local/bin/done_idt_init ];then
|
||||||
|
echo "There is a done_idt_init file"
|
||||||
|
else
|
||||||
|
|
||||||
|
cat /etc/init.d/opennsl-modules-4.9.0-7-amd64|grep idt_init.sh
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
echo "Add idt_init.sh to opennsl-modules for TD3 MAC"
|
||||||
|
sed -i '/modprobe linux-kernel-bde/i sleep 1' /etc/init.d/opennsl-modules-4.9.0-7-amd64
|
||||||
|
sed -i '/sleep/i /usr/local/bin/idt_init.sh' /etc/init.d/opennsl-modules-4.9.0-7-amd64
|
||||||
|
sed -i '/idt_init/i echo "IDT init" ' /etc/init.d/opennsl-modules-4.9.0-7-amd64
|
||||||
|
sed -i '/IDT init/i echo 1 > /usr/local/bin/done_idt_init' /etc/init.d/opennsl-modules-4.9.0-7-amd64
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
150
platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/idt_init.sh
Executable file
150
platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/idt_init.sh
Executable file
@ -0,0 +1,150 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
test_log=/usr/local/bin/check_idt_status.txt
|
||||||
|
modprobe i2c-i801
|
||||||
|
modprobe i2c-dev
|
||||||
|
i2cset -y 0 0x77 0x1
|
||||||
|
i2cset -y 0 0x70 0x1
|
||||||
|
i2cget -y 0 0x54 0 b > /dev/null
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
printf "Device 8v89307(0x54) not found\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "IDT 82V89307 "
|
||||||
|
echo "idt init 1"
|
||||||
|
# Title = --- IDT 82V89307 Registers ---
|
||||||
|
#Select to Page 0
|
||||||
|
i2cset -y 0 0x54 0x2D 0x00
|
||||||
|
i2cset -y 0 0x54 0x7F 0x05
|
||||||
|
i2cset -y 0 0x54 0x7E 0x85
|
||||||
|
i2cset -y 0 0x54 0x7B 0x00
|
||||||
|
i2cset -y 0 0x54 0x7A 0x00
|
||||||
|
i2cset -y 0 0x54 0x79 0x40
|
||||||
|
i2cset -y 0 0x54 0x78 0x06
|
||||||
|
i2cset -y 0 0x54 0x73 0x40
|
||||||
|
i2cset -y 0 0x54 0x72 0x40
|
||||||
|
|
||||||
|
# OUT3:25MHz
|
||||||
|
i2cset -y 0 0x54 0x71 0x0A
|
||||||
|
i2cset -y 0 0x54 0x70 0x00
|
||||||
|
|
||||||
|
# OUT1:1pps
|
||||||
|
i2cset -y 0 0x54 0x6B 0x4E
|
||||||
|
i2cset -y 0 0x54 0x69 0x00
|
||||||
|
i2cset -y 0 0x54 0x68 0x00
|
||||||
|
i2cset -y 0 0x54 0x67 0x19
|
||||||
|
i2cset -y 0 0x54 0x66 0xAB
|
||||||
|
i2cset -y 0 0x54 0x65 0x8C
|
||||||
|
i2cset -y 0 0x54 0x64 0x00
|
||||||
|
i2cset -y 0 0x54 0x63 0x00
|
||||||
|
i2cset -y 0 0x54 0x62 0x00
|
||||||
|
i2cset -y 0 0x54 0x5F 0x00
|
||||||
|
i2cset -y 0 0x54 0x5E 0x00
|
||||||
|
i2cset -y 0 0x54 0x5D 0x00
|
||||||
|
i2cset -y 0 0x54 0x5C 0x78
|
||||||
|
i2cset -y 0 0x54 0x5B 0x02
|
||||||
|
i2cset -y 0 0x54 0x5A 0xE5
|
||||||
|
i2cset -y 0 0x54 0x59 0x88
|
||||||
|
i2cset -y 0 0x54 0x58 0x4B
|
||||||
|
i2cset -y 0 0x54 0x57 0x6C
|
||||||
|
i2cset -y 0 0x54 0x56 0x6C
|
||||||
|
|
||||||
|
# Lock to DPLL, output 625MHz
|
||||||
|
i2cset -y 0 0x54 0x55 0x80
|
||||||
|
i2cset -y 0 0x54 0x53 0x00
|
||||||
|
i2cset -y 0 0x54 0x52 0x81
|
||||||
|
i2cset -y 0 0x54 0x50 0x00
|
||||||
|
i2cset -y 0 0x54 0x4F 0x00
|
||||||
|
i2cset -y 0 0x54 0x4E 0x00
|
||||||
|
i2cset -y 0 0x54 0x4C 0xCB
|
||||||
|
i2cset -y 0 0x54 0x4A 0x00
|
||||||
|
i2cset -y 0 0x54 0x45 0x66
|
||||||
|
i2cset -y 0 0x54 0x44 0x66
|
||||||
|
i2cset -y 0 0x54 0x42 0x80
|
||||||
|
i2cset -y 0 0x54 0x41 0x03
|
||||||
|
i2cset -y 0 0x54 0x40 0x01
|
||||||
|
i2cset -y 0 0x54 0x3F 0x08
|
||||||
|
i2cset -y 0 0x54 0x3E 0x04
|
||||||
|
i2cset -y 0 0x54 0x3D 0x20
|
||||||
|
i2cset -y 0 0x54 0x3C 0x13
|
||||||
|
i2cset -y 0 0x54 0x3B 0x00
|
||||||
|
i2cset -y 0 0x54 0x3A 0x98
|
||||||
|
i2cset -y 0 0x54 0x39 0x01
|
||||||
|
i2cset -y 0 0x54 0x38 0xE6
|
||||||
|
i2cset -y 0 0x54 0x37 0x04
|
||||||
|
i2cset -y 0 0x54 0x36 0xCE
|
||||||
|
i2cset -y 0 0x54 0x35 0x7C
|
||||||
|
i2cset -y 0 0x54 0x34 0x01
|
||||||
|
i2cset -y 0 0x54 0x33 0x08
|
||||||
|
i2cset -y 0 0x54 0x32 0x08
|
||||||
|
i2cset -y 0 0x54 0x31 0x08
|
||||||
|
i2cset -y 0 0x54 0x30 0x03
|
||||||
|
i2cset -y 0 0x54 0x2F 0x23
|
||||||
|
i2cset -y 0 0x54 0x2E 0x0B
|
||||||
|
i2cset -y 0 0x54 0x2D 0x00
|
||||||
|
i2cset -y 0 0x54 0x28 0x76
|
||||||
|
i2cset -y 0 0x54 0x27 0x54
|
||||||
|
i2cset -y 0 0x54 0x25 0x00
|
||||||
|
i2cset -y 0 0x54 0x24 0x03
|
||||||
|
i2cset -y 0 0x54 0x23 0x06
|
||||||
|
i2cset -y 0 0x54 0x1A 0x8C
|
||||||
|
i2cset -y 0 0x54 0x19 0x8C
|
||||||
|
i2cset -y 0 0x54 0x18 0x00
|
||||||
|
i2cset -y 0 0x54 0x16 0x0D
|
||||||
|
i2cset -y 0 0x54 0x11 0x00
|
||||||
|
i2cset -y 0 0x54 0x10 0x00
|
||||||
|
i2cset -y 0 0x54 0x0E 0x3F
|
||||||
|
i2cset -y 0 0x54 0x0D 0xFF
|
||||||
|
i2cset -y 0 0x54 0x0C 0x02
|
||||||
|
i2cset -y 0 0x54 0x0B 0xA1
|
||||||
|
i2cset -y 0 0x54 0x0A 0x89
|
||||||
|
i2cset -y 0 0x54 0x09 0xA2
|
||||||
|
i2cset -y 0 0x54 0x08 0x32
|
||||||
|
i2cset -y 0 0x54 0x06 0x00
|
||||||
|
i2cset -y 0 0x54 0x05 0x00
|
||||||
|
i2cset -y 0 0x54 0x04 0x00
|
||||||
|
i2cset -y 0 0x54 0x03 0x00
|
||||||
|
i2cset -y 0 0x54 0x02 0x05
|
||||||
|
i2cset -y 0 0x54 0x01 0x33
|
||||||
|
i2cset -y 0 0x54 0x00 0x91
|
||||||
|
|
||||||
|
echo "idt init 2"
|
||||||
|
# PreDivider_Parameters
|
||||||
|
#IN1
|
||||||
|
i2cset -y 0 0x54 0x23 0x05
|
||||||
|
i2cset -y 0 0x54 0x24 0x03
|
||||||
|
i2cset -y 0 0x54 0x25 0x00
|
||||||
|
#IN2
|
||||||
|
i2cset -y 0 0x54 0x23 0x06
|
||||||
|
i2cset -y 0 0x54 0x24 0x03
|
||||||
|
i2cset -y 0 0x54 0x25 0x00
|
||||||
|
#IN3
|
||||||
|
i2cset -y 0 0x54 0x23 0x03
|
||||||
|
i2cset -y 0 0x54 0x24 0x00
|
||||||
|
i2cset -y 0 0x54 0x25 0x00
|
||||||
|
|
||||||
|
echo "idt init 3"
|
||||||
|
# Page1_Parameters
|
||||||
|
#Select to Page 1
|
||||||
|
i2cset -y 0 0x54 0x2D 0x01
|
||||||
|
i2cset -y 0 0x54 0x30 0x03
|
||||||
|
i2cset -y 0 0x54 0x31 0x08
|
||||||
|
i2cset -y 0 0x54 0x32 0x08
|
||||||
|
i2cset -y 0 0x54 0x33 0x08
|
||||||
|
i2cset -y 0 0x54 0x35 0x7C
|
||||||
|
i2cset -y 0 0x54 0x36 0xCE
|
||||||
|
i2cset -y 0 0x54 0x37 0x04
|
||||||
|
i2cset -y 0 0x54 0x38 0xE6
|
||||||
|
i2cset -y 0 0x54 0x39 0x01
|
||||||
|
i2cset -y 0 0x54 0x3A 0x98
|
||||||
|
i2cset -y 0 0x54 0x3B 0x00
|
||||||
|
i2cset -y 0 0x54 0x3C 0x13
|
||||||
|
i2cset -y 0 0x54 0x3D 0x20
|
||||||
|
#Return to Page 0
|
||||||
|
i2cset -y 0 0x54 0x2D 0x00
|
||||||
|
|
||||||
|
echo "idt init 4"
|
||||||
|
#reset the in-path mux
|
||||||
|
i2cset -y 0 0x70 0x0
|
||||||
|
i2cset -y 0 0x77 0x0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user