refactor(script : nicsensor.sh)Update to version 1.2 Intest Rev7

1.重构detect部分的代码,增强代码可读性与整洁性
This commit is contained in:
marcinlei 2024-11-28 23:13:26 +08:00
parent 87e0d2b00a
commit 9eb8564b6c

@ -133,7 +133,7 @@ ina3221_ch2_volt="0"
ina3221_ch0_current="0" ina3221_ch0_current="0"
ina3221_ch1_current="0" ina3221_ch1_current="0"
ina3221_ch2_current="0" ina3221_ch2_current="0"
SCRIPT_VERSION="1.2 InTest Rev6" SCRIPT_VERSION="1.2 InTest Rev7"
fru_file_name=$option_data2 fru_file_name=$option_data2
fru_write_size=0 fru_write_size=0
@ -189,6 +189,18 @@ format_log_print(){
echo "[$1] $2" >> $log echo "[$1] $2" >> $log
} }
# 切换一次9548的channel并进行一次标准的i2cdetect
# @Param1 i2c bus number
# @Param2 pca9548 slave address
# @Param3 pca9548 channel hex value
# @Param4 pca9548 channel
# @Param5 pcie slot number
do_i2c_detect(){
format_print $INFO "PCIe slot $5 : bus$1 9548channel$4"
i2ctransfer -y $1 w1@$2 $3
i2cdetect -y $1
}
# 自查一些脚本中的属性配置 # 自查一些脚本中的属性配置
conf_pre_check(){ conf_pre_check(){
@ -927,33 +939,17 @@ detect_on_5280m7(){
pca9641_slave="0x41" pca9641_slave="0x41"
get_pca9641_controll get_pca9641_controll
format_print $INFO "PCIe slot 0 : bus12 9548channel 1" do_i2c_detect 12 0x72 0x02 1 0
i2ctransfer -y $i2c_bus w1@0x72 0x02 do_i2c_detect 12 0x72 0x04 2 1
i2cdetect -y $i2c_bus do_i2c_detect 12 0x72 0x08 3 2
format_print $INFO "PCIe slot 1 : bus12 9548channel 2"
i2ctransfer -y $i2c_bus w1@0x72 0x04
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 2 : bus12 9548channel 3"
i2ctransfer -y $i2c_bus w1@0x72 0x08
i2cdetect -y $i2c_bus
i2c_bus=13 i2c_bus=13
pca9641_slave="0x42" pca9641_slave="0x42"
get_pca9641_controll get_pca9641_controll
format_print $INFO "PCIe slot 3 : bus13 9548channel 1" do_i2c_detect 13 0x72 0x02 1 3
i2ctransfer -y $i2c_bus w1@0x72 0x02 do_i2c_detect 13 0x72 0x04 2 4
i2cdetect -y $i2c_bus do_i2c_detect 13 0x72 0x08 3 5
format_print $INFO "PCIe slot 4 : bus13 9548channel 2"
i2ctransfer -y $i2c_bus w1@0x72 0x04
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 5 : bus13 9548channel 3"
i2ctransfer -y $i2c_bus w1@0x72 0x08
i2cdetect -y $i2c_bus
} }
# 在 5468m7 上扫描每个pcie slot下的I2C设备 # 在 5468m7 上扫描每个pcie slot下的I2C设备
@ -963,162 +959,66 @@ detect_on_5468m7(){
pca9641_slave="0x31" pca9641_slave="0x31"
get_pca9641_controll get_pca9641_controll
format_print $INFO "PCIe slot 0 : bus13 9548channel 0" do_i2c_detect 13 0x70 0x01 0 0
i2ctransfer -y $i2c_bus w1@0x70 0x01 do_i2c_detect 13 0x70 0x02 1 1
i2cdetect -y $i2c_bus do_i2c_detect 13 0x70 0x04 2 2
do_i2c_detect 13 0x70 0x08 3 3
format_print $INFO "PCIe slot 1 : bus13 9548channel 1" do_i2c_detect 13 0x70 0x10 4 4
i2ctransfer -y $i2c_bus w1@0x70 0x02
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 2 : bus13 9548channel 2"
i2ctransfer -y $i2c_bus w1@0x70 0x04
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 3 : bus13 9548channel 3"
i2ctransfer -y $i2c_bus w1@0x70 0x08
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 4 : bus13 9548channel 4"
i2ctransfer -y $i2c_bus w1@0x70 0x10
i2cdetect -y $i2c_bus
i2c_bus=14 i2c_bus=14
pca9641_slave="0x42" pca9641_slave="0x42"
get_pca9641_controll get_pca9641_controll
format_print $INFO "PCIe slot 5 : bus14 9548channel 0" do_i2c_detect 14 0x71 0x01 0 5
i2ctransfer -y $i2c_bus w1@0x71 0x01 do_i2c_detect 14 0x71 0x02 1 6
i2cdetect -y $i2c_bus do_i2c_detect 14 0x71 0x04 2 7
do_i2c_detect 14 0x71 0x08 3 8
format_print $INFO "PCIe slot 6 : bus14 9548channel 1" do_i2c_detect 14 0x71 0x10 4 9
i2ctransfer -y $i2c_bus w1@0x71 0x02 do_i2c_detect 14 0x71 0x20 5 10
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 7 : bus14 9548channel 2"
i2ctransfer -y $i2c_bus w1@0x71 0x04
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 8 : bus14 9548channel 3"
i2ctransfer -y $i2c_bus w1@0x71 0x08
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 9 : bus14 9548channel 4"
i2ctransfer -y $i2c_bus w1@0x71 0x10
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 10 : bus14 9548channel 5"
i2ctransfer -y $i2c_bus w1@0x71 0x20
i2cdetect -y $i2c_bus
} }
# 在 donghu 上扫描每个pcie slot下的I2C设备 # 在 donghu 上扫描每个pcie slot下的I2C设备
detect_on_donghu(){ detect_on_donghu(){
i2c_bus=3 i2c_bus=3
do_i2c_detect 3 0x70 0x80 7 0
format_print $INFO "PCIe slot 0 : bus3 9548channel 7" do_i2c_detect 3 0x70 0x40 6 1
i2ctransfer -y $i2c_bus w1@0x70 0x80 do_i2c_detect 3 0x70 0x20 5 2
i2cdetect -y $i2c_bus do_i2c_detect 3 0x70 0x10 4 3
do_i2c_detect 3 0x70 0x08 3 4
format_print $INFO "PCIe slot 1 : bus3 9548channel 6" do_i2c_detect 3 0x70 0x04 2 5
i2ctransfer -y $i2c_bus w1@0x70 0x40 do_i2c_detect 3 0x70 0x02 1 6
i2cdetect -y $i2c_bus do_i2c_detect 3 0x70 0x01 0 7
format_print $INFO "PCIe slot 2 : bus3 9548channel 5"
i2ctransfer -y $i2c_bus w1@0x70 0x20
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 3 : bus3 9548channel 4"
i2ctransfer -y $i2c_bus w1@0x70 0x10
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 4 : bus3 9548channel 3"
i2ctransfer -y $i2c_bus w1@0x70 0x08
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 5 : bus3 9548channel 2"
i2ctransfer -y $i2c_bus w1@0x70 0x04
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 6 : bus3 9548channel 1"
i2ctransfer -y $i2c_bus w1@0x70 0x02
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 7 : bus3 9548channel 0"
i2ctransfer -y $i2c_bus w1@0x70 0x01
i2cdetect -y $i2c_bus
} }
# 在 yichun 上扫描每个pcie slot下的I2C设备 # 在 yichun 上扫描每个pcie slot下的I2C设备
detect_on_yichun(){ detect_on_yichun(){
i2c_bus=12 i2c_bus=12
format_print $INFO "PCIe slot 0 : bus12 9546channel 2" do_i2c_detect 12 0x74 0x02 2 0
i2ctransfer -y $i2c_bus w1@0x74 0x02
i2cdetect -y $i2c_bus
i2c_bus=13 i2c_bus=13
format_print $INFO "PCIe slot 1 : bus13 9546channel 2" do_i2c_detect 13 0x74 0x02 2 1
i2ctransfer -y $i2c_bus w1@0x74 0x02
i2cdetect -y $i2c_bus
i2c_bus=14 i2c_bus=14
format_print $INFO "PCIe slot 2 : bus14 9546channel 2" do_i2c_detect 14 0x74 0x02 2 2
i2ctransfer -y $i2c_bus w1@0x74 0x02
i2cdetect -y $i2c_bus
} }
# 在 qiandaohu 上扫描每个pcie slot下的I2C设备 # 在 qiandaohu 上扫描每个pcie slot下的I2C设备
detect_on_qiandaohu(){ detect_on_qiandaohu(){
i2c_bus=3 i2c_bus=3
format_print $INFO "PCIe slot 0 : bus3 9548channel 3" do_i2c_detect 3 0x70 0x08 3 0
i2ctransfer -y $i2c_bus w1@0x70 0x08 do_i2c_detect 3 0x70 0x04 2 1
i2cdetect -y $i2c_bus do_i2c_detect 3 0x70 0x01 0 2
do_i2c_detect 3 0x70 0x02 1 3
format_print $INFO "PCIe slot 1 : bus3 9548channel 2" do_i2c_detect 3 0x70 0x80 7 4
i2ctransfer -y $i2c_bus w1@0x70 0x04 do_i2c_detect 3 0x70 0x40 6 5
i2cdetect -y $i2c_bus do_i2c_detect 3 0x70 0x10 4 6
do_i2c_detect 3 0x70 0x20 5 7
format_print $INFO "PCIe slot 2 : bus3 9548channel 0"
i2ctransfer -y $i2c_bus w1@0x70 0x01
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 3 : bus3 9548channel 1"
i2ctransfer -y $i2c_bus w1@0x70 0x02
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 4 : bus3 9548channel 7"
i2ctransfer -y $i2c_bus w1@0x70 0x80
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 5 : bus3 9548channel 6"
i2ctransfer -y $i2c_bus w1@0x70 0x40
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 6 : bus3 9548channel 4"
i2ctransfer -y $i2c_bus w1@0x70 0x10
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 7 : bus3 9548channel 5"
i2ctransfer -y $i2c_bus w1@0x70 0x20
i2cdetect -y $i2c_bus
i2c_bus=6 i2c_bus=6
format_print $INFO "PCIe slot 8 : bus6 9548channel 3" do_i2c_detect 6 0x71 0x08 3 8
i2ctransfer -y $i2c_bus w1@0x71 0x08 do_i2c_detect 6 0x71 0x04 2 9
i2cdetect -y $i2c_bus do_i2c_detect 6 0x71 0x01 0 10
do_i2c_detect 6 0x71 0x08 3 11
format_print $INFO "PCIe slot 9 : bus6 9548channel 2"
i2ctransfer -y $i2c_bus w1@0x71 0x04
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 10 : bus6 9548channel 0"
i2ctransfer -y $i2c_bus w1@0x71 0x01
i2cdetect -y $i2c_bus
format_print $INFO "PCIe slot 11 : bus6 9548channel 3"
i2ctransfer -y $i2c_bus w1@0x71 0x02
i2cdetect -y $i2c_bus
} }
# 搜索服务器所有PCIE插槽的I2C设备信息,仅支持特定Riser卡上的设备 # 搜索服务器所有PCIE插槽的I2C设备信息,仅支持特定Riser卡上的设备