fix(script : nicsensor.sh) update to version 1.3Intest Rev3

1.修复adc128的读取
2.完善5280m7服务器适配
3.优化显示
This commit is contained in:
leimingsheng 2024-12-11 16:58:14 +08:00
parent 7e3a6a1c38
commit 5ad98b9226

@ -15,14 +15,14 @@ votage_division_factor_6="0.2326"
votage_division_factor_7="1" votage_division_factor_7="1"
# ADC128 channel name # ADC128 channel name
ADC128_Channel0_name="Channel 0" ADC128_Channel0_name="Channel0"
ADC128_Channel1_name="Channel 1" ADC128_Channel1_name="Channel1"
ADC128_Channel2_name="Channel 2" ADC128_Channel2_name="Channel2"
ADC128_Channel3_name="Channel 3" ADC128_Channel3_name="Channel3"
ADC128_Channel4_name="Channel 4" ADC128_Channel4_name="Channel4"
ADC128_Channel5_name="Channel 5" ADC128_Channel5_name="Channel5"
ADC128_Channel6_name="Channel 6" ADC128_Channel6_name="Channel6"
ADC128_Channel7_name="Channel 7" ADC128_Channel7_name="Channel7"
# INA3221 shunt resistor(unit: mohm) # INA3221 shunt resistor(unit: mohm)
shunt_resistor_0="2" shunt_resistor_0="2"
@ -30,14 +30,14 @@ shunt_resistor_1="2"
shunt_resistor_2="5" shunt_resistor_2="5"
# INA3221 channel name # INA3221 channel name
INA3221_Channel0_name="Channel 0" INA3221_Channel0_name="Channel0"
INA3221_Channel1_name="Channel 1" INA3221_Channel1_name="Channel1"
INA3221_Channel2_name="Channel 2" INA3221_Channel2_name="Channel2"
# EMC1413 channel name # EMC1413 channel name
EMC1413_Channel0_name="Channel 0" EMC1413_Channel0_name="Channel0"
EMC1413_Channel1_name="Channel 1" EMC1413_Channel1_name="Channel1"
EMC1413_Channel2_name="Channel 2" EMC1413_Channel2_name="Channel2"
# fru basic offset # fru basic offset
fru_offset="0x00 0x00" fru_offset="0x00 0x00"
@ -117,7 +117,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.3 Intest Rev2" SCRIPT_VERSION="1.3 Intest Rev3"
fru_file_name=$option_data2 fru_file_name=$option_data2
fru_write_size=0 fru_write_size=0
@ -132,7 +132,7 @@ slot_number=""
# script usage # script usage
print_usage(){ print_usage(){
echo "" echo ""
echo "================>>> nicsensor script usage <<<=================" echo "================>>> nicsensor script usage <<<=================="
echo " Command Format : ./nicsensor.sh [slot] [sensor tpye] [slave]" echo " Command Format : ./nicsensor.sh [slot] [sensor tpye] [slave]"
echo " Option Detail" echo " Option Detail"
echo " [slot] : 0 1 2 3 4 5 ..." echo " [slot] : 0 1 2 3 4 5 ..."
@ -194,7 +194,7 @@ do_i2c_detect(){
# script self test # script self test
conf_pre_check(){ conf_pre_check(){
# check DEBUG_MODE value # check DEBUG_MODE value
if [ $DEBUG_MODE -ne 0 && $DEBUG_MODE -ne 1 ];then if [ $DEBUG_MODE -ne 0 ] && [ $DEBUG_MODE -ne 1 ];then
format_print $ERROR "Invalid conf value, DEBUG_MODE: $DEBUG_MODE" format_print $ERROR "Invalid conf value, DEBUG_MODE: $DEBUG_MODE"
exit 1 exit 1
fi fi
@ -206,6 +206,7 @@ set_configuration_5280m7(){
if [ $nic_type == "ocp" ];then if [ $nic_type == "ocp" ];then
is_have_pca9641=0 is_have_pca9641=0
pca9548_slave="0x70" pca9548_slave="0x70"
i2c_bus=3
else else
is_have_pca9641=1 is_have_pca9641=1
if [ $slot_number -le 2 ];then if [ $slot_number -le 2 ];then
@ -435,8 +436,8 @@ init_debuglog(){
fi fi
# print time header # print time header
res_date=`date` res_date=`date +%Y-%m-%dT%H:%M:%S`
format_log_print $INFO "=========================== $res_date" format_log_print $INFO "Start Time : $res_date"
format_log_print $INFO "Script Version : $SCRIPT_VERSION" format_log_print $INFO "Script Version : $SCRIPT_VERSION"
if [ $DEBUG_MODE -ne 0 ];then if [ $DEBUG_MODE -ne 0 ];then
@ -449,7 +450,7 @@ prepare_start_info(){
format_log_print $INFO "PCIE slot : $nic_slot" format_log_print $INFO "PCIE slot : $nic_slot"
format_log_print $INFO "I2C Bus: $i2c_bus" format_log_print $INFO "I2C Bus: $i2c_bus"
if [ $is_have_pca9641 -eq 1];then if [ $is_have_pca9641 -eq 1 ];then
format_log_print $INFO "PCA9641 slave: $pca9641_slave" format_log_print $INFO "PCA9641 slave: $pca9641_slave"
fi fi
format_log_print $INFO "PCA9548 slave: $pca9548_slave" format_log_print $INFO "PCA9548 slave: $pca9548_slave"
@ -851,7 +852,7 @@ read_fru(){
res_fru=`i2ctransfer -y $i2c_bus w2@$chip_slave $fru_offset r256` res_fru=`i2ctransfer -y $i2c_bus w2@$chip_slave $fru_offset r256`
# print fru data every 16 bytes per row # print fru data every 16 bytes per row
echo "The Fru Data :" format_print $INFO "The Fru Data :"
echo "$res_fru" | \ echo "$res_fru" | \
awk '{ awk '{
line=""; line="";
@ -880,7 +881,7 @@ read_fru(){
} }
# !!! untest function !!!s # !!! untest function !!!
write_fru(){ write_fru(){
i2c_write_byte=$(($fru_write_size+2)) i2c_write_byte=$(($fru_write_size+2))
@ -947,22 +948,20 @@ start_get_sensor(){
esac esac
} }
#@Param1 nic type
detect_on_5280m7(){ detect_on_5280m7(){
if [ $nic_type == "ocp" ];then
if [ $1 == "ocp" ];then
i2c_bus=3 i2c_bus=3
do_i2c_detect 3 0x70 0x01 0 0 do_i2c_detect 3 0x70 0x01 0 0
do_i2c_detect 3 0x70 0x02 1 1 do_i2c_detect 3 0x70 0x02 1 1
do_i2c_detect 3 0x70 0x04 2 2 do_i2c_detect 3 0x70 0x04 2 2
else else
i2c_bus=12 # i2c_bus=12
pca9641_slave="0x41" # pca9641_slave="0x41"
get_pca9641_control # get_pca9641_control
do_i2c_detect 12 0x72 0x02 1 0 # do_i2c_detect 12 0x72 0x02 1 0
do_i2c_detect 12 0x72 0x04 2 1 # do_i2c_detect 12 0x72 0x04 2 1
do_i2c_detect 12 0x72 0x08 3 2 # do_i2c_detect 12 0x72 0x08 3 2
i2c_bus=13 i2c_bus=13
pca9641_slave="0x42" pca9641_slave="0x42"
@ -1055,7 +1054,7 @@ start_detect_device(){
exit 0 exit 0
fi fi
format_print $INFO "Detect on server : $server_type" format_print $INFO "Detect on server : $server_type, nic type: $nic_type"
case $server_type in case $server_type in
"5280m7") "5280m7")
detect_on_5280m7 detect_on_5280m7
@ -1094,8 +1093,16 @@ if [ "$sensor_type" == "chip" ];then
fi fi
if [ "$1" == "detect" ];then if [ "$1" == "detect" ];then
nic_type=$2 if [ "$2" == "ocp" ];then
start_detect_device $nic_type nic_type="ocp"
elif [ "$2" == "pcie" ];then
nic_type="pcie"
else
format_print $WARNING "Please provide valid nic type, default to pcie"
nic_type="pcie"
fi
start_detect_device
exit 0 exit 0
fi fi