update code stucture

This commit is contained in:
leimingsheng 2024-11-07 14:53:35 +08:00
parent 6b401d534d
commit 64b7c0b9d8
7 changed files with 64 additions and 56 deletions

@ -5,48 +5,20 @@
# 支持通过 chip 参数直接做I2C命令透传来访问芯片寄存器
# 支持通过 fru 参数读取FRU十六进制内容
# ---------------------------------------------------------
# Project Feature Varible (按照项目需要修改)
# ---------------------------------------------------------
# 应用的服务器产品,根据服务器产品手动修改这个变量
# 当前适配的服务器产品 5280m7 5468m7 donghu yichun
server_type="5280m7"
# ---------------------------------------------------------
# Common Varible (请勿随意修改)
# ---------------------------------------------------------
# Input Param
# Introduction of pcie_slot
# 1.脚本即将访问的网卡位于服务器上的PCIe插槽位置
pcie_slot=$1
# Introduction of sensor_type
# 1.脚本即将读取和处理的传感器名称
sensor_type=$2
# Introduction of chip_slave
# 1.chip i2c slave address(7bit)
chip_slave=$3
# Introduction of option_data
# 1.在FRU的处理过程中,使用option_data来区分是读操作还是写操作,将值设置为
# "read"或者"write"
# 2.在chip的处理过程中,使用option_data来代表一条完整的i2c命令,这条命令会
# 被发到chip上,一个例子:"i2ctransfer -y 12 w2@0x10 0x90 0x00 r9"
option_data=$4
# Introduction of option_data2
# 1.仅用于fru write操作代表即将写入的fru文件名
option_data2=$5
# CHIP REGISTER
REG_pca9641_controll="0x01"
# ---------------------------------------------------------
# Global Varible (请勿随意修改)
# ---------------------------------------------------------
# DEBUG MODE=0 : Disable debug mode
# =1 : Enable debug mode
# 启用debug模式后需要手动配置 i2c_bus
@ -70,9 +42,14 @@ SCRIPT_VRESION="1.2 InTest Rev3"
fru_file_name=$option_data2
# ---------------------------------------------------------
# Script Function Defination
# ---------------------------------------------------------
DIR=`pwd`
ADC128="$DIR/plugin/adc128.sh"
EMC1413="$DIR/plugin/emc1413.sh"
INA3221="$DIR/plugin/ina3221.sh"
CHIP="$DIR/plugin/chip.sh"
FRU="$DIR/plugin/fru.sh"
DETECT="$DIR/plugin/detect.sh"
# script usage
print_usage(){
@ -283,6 +260,25 @@ init_debuglog(){
if [ $DEBUG_MODE -ne 0 ];then
format_log_print $WARNING "Enable debug mode : $DEBUG_MODE"
fi
if [ ! -f $ADC128 ];then
format_log_print $WARNING "Can't find plugin $ADC128"
fi
if [ ! -f $EMC1413 ];then
format_log_print $WARNING "Can't find plugin $EMC1413"
fi
if [ ! -f $INA3221 ];then
format_log_print $WARNING "Can't find plugin $INA3221"
fi
if [ ! -f $CHIP ];then
format_log_print $WARNING "Can't find plugin $CHIP"
fi
if [ ! -f $FRU ];then
format_log_print $WARNING "Can't find plugin $FRU"
fi
if [ ! -f $DETECT ];then
format_log_print $WARNING "Can't find plugin $DETECT"
fi
}
# 记录配置信息日志
@ -333,11 +329,6 @@ switch_pca9548_channel(){
echo $res_after >> $log
}
# ---------------------------------------------------------
# Chip EMC1413
# ---------------------------------------------------------
# EMC1413处理逻辑
process_emc1413(){
# emc1413 no need to init
@ -345,10 +336,6 @@ process_emc1413(){
read_emc1413_channel_value
}
# ---------------------------------------------------------
# Chip ADC128
# ---------------------------------------------------------
# ADC128处理逻辑
process_adc128(){
# check if chip adc128 need init
check_adc128_init
@ -357,10 +344,6 @@ process_adc128(){
read_adc128_channel_value
}
# ---------------------------------------------------------
# Chip INA3221
# ---------------------------------------------------------
# INA3221处理逻辑
process_ina3221(){
# ina3221 no need to init first
@ -369,10 +352,6 @@ process_ina3221(){
read_ina3221_channel_value
}
# ---------------------------------------------------------
# CHIP
# ---------------------------------------------------------
# chip处理逻辑
process_chip(){
# cpld no need to init first
@ -382,10 +361,6 @@ process_chip(){
}
# ---------------------------------------------------------
# FRU
# ---------------------------------------------------------
# fru 处理逻辑
process_fru(){
# fru no need to init first
@ -397,9 +372,6 @@ process_fru(){
read_fru
fi
}
# ---------------------------------------------------------
# END of CHIP Function
# ---------------------------------------------------------
# 读取sensor流程的起点
start_get_sensor(){
@ -476,7 +448,7 @@ if [ "$sensor_type" == "fru" ];then
fi
# 解析fru bin文件
parse_fru_write_data
$parse_fru_write_data
fi
fi

@ -1,5 +1,11 @@
#!/bin/sh
log="/tmp/nicsensor_debug.log"
INFO="Info"
WARNING="Warning"
ERROR="Error"
votage_division_factor_0="1"
votage_division_factor_1="1"
votage_division_factor_2="1"

@ -1,5 +1,11 @@
#!/bin/sh
log="/tmp/nicsensor_debug.log"
INFO="Info"
WARNING="Warning"
ERROR="Error"
# 临时支持CHIP读取寄存器
write_read_chip(){

@ -1,5 +1,11 @@
#!/bin/sh
log="/tmp/nicsensor_debug.log"
INFO="Info"
WARNING="Warning"
ERROR="Error"
# 在 5280m7 上扫描每个pcie slot下的I2C设备
# 详细对应关系参阅 readme.txt 第二节
detect_on_5280m7(){

@ -1,5 +1,11 @@
#!/bin/sh
log="/tmp/nicsensor_debug.log"
INFO="Info"
WARNING="Warning"
ERROR="Error"
EMC1413_Channel0_name="Channel 0"
EMC1413_Channel1_name="Channel 1"
EMC1413_Channel2_name="Channel 2"

@ -1,5 +1,11 @@
#!/bin/sh
log="/tmp/nicsensor_debug.log"
INFO="Info"
WARNING="Warning"
ERROR="Error"
# fru 烧录的起始地址
fru_offset="0x00 0x00"

@ -1,5 +1,11 @@
#!/bin/sh
log="/tmp/nicsensor_debug.log"
INFO="Info"
WARNING="Warning"
ERROR="Error"
shunt_resistor_0="2"
shunt_resistor_1="2"
shunt_resistor_2="5"