feat(script : nicsensor.sh)Update to version 1.3 Intest Rev6

1.优化支持列表的交互
2.在debug mode下检查定制化名称是否符合规范
This commit is contained in:
leimingsheng 2024-12-19 16:53:08 +08:00
parent 6458d5daa4
commit 3ca7de0ecf

@ -51,13 +51,14 @@ TMP468_Channel7_name="Remote7"
TMP468_Channel8_name="Remote8"
# TMP112 sensor name
TMP112_Sensor_name="tmp112"
TMP112_Sensor_name="Temperature"
# fru basic offset
fru_offset="0x00 0x00"
Support_Sensor_List="emc1413, adc128, ina3221, tmp468, tmp112"
Support_Server_List="5280m7, 5468m7, donghu, yichun, qiandaohu"
# Which server will use this script
# Please set to :5280m7 5468m7 donghu yichun qiandaohu
server_type="5280m7"
# ---------------------------------------------------------
@ -133,7 +134,7 @@ ina3221_ch2_volt="0"
ina3221_ch0_current="0"
ina3221_ch1_current="0"
ina3221_ch2_current="0"
SCRIPT_VERSION="1.3 Intest Rev5"
SCRIPT_VERSION="1.3 Intest Rev6"
fru_file_name=$option_data2
fru_write_size=0
@ -153,13 +154,14 @@ print_usage(){
echo " Command Format : ./nicsensor.sh [slot] [sensor tpye] [slave]"
echo " Option Detail"
echo " [slot] : 0 1 2 3 4 5 ..."
echo " [sensor type] : emc1413, adc128, ina3221, tmp468, tmp112"
echo " [sensor type] : $Support_Sensor_List"
echo " [slave] : chip slave address , please provide 7 bit address"
echo " E.G. : ./nicsensor.sh 0 adc128 0x1f"
echo ""
echo " To Auto detect i2c slave on server, please use:"
echo " ./nicsensor.sh detect"
echo " This function now only support on server 5280m7, 5468m7, donghu, yichun, qiandaohu"
echo " This function now only support on server:"
echo " $Support_Server_List"
echo ""
echo " If want to read/write chip register, use the below format"
echo " ./nicsensor.sh [slot] chip [slave] [i2c_command]"
@ -192,6 +194,14 @@ format_log_print(){
echo "[$1] $2" >> $log
}
# Customization name cant contain the space character
# @Param1 : name
check_customization_name(){
if [ "$1" == *" "* ];then
format_log_print $ERROR "'$1' has a space, invalid name"
fi
}
# switch pca9548 channels then do i2cdetect one times
# @Param1 i2c bus number
# @Param2 pca9548 slave address
@ -215,6 +225,38 @@ conf_pre_check(){
format_print $ERROR "Invalid conf value, DEBUG_MODE: $DEBUG_MODE"
exit 1
fi
# In debug mode, check channel name
if [ $DEBUG_MODE -eq 1];then
check_customization_name "$ADC128_Channel0_name"
check_customization_name "$ADC128_Channel1_name"
check_customization_name "$ADC128_Channel2_name"
check_customization_name "$ADC128_Channel3_name"
check_customization_name "$ADC128_Channel4_name"
check_customization_name "$ADC128_Channel5_name"
check_customization_name "$ADC128_Channel6_name"
check_customization_name "$ADC128_Channel7_name"
check_customization_name "$INA3221_Channel0_name"
check_customization_name "$INA3221_Channel1_name"
check_customization_name "$INA3221_Channel2_name"
check_customization_name "$EMC1413_Channel0_name"
check_customization_name "$EMC1413_Channel1_name"
check_customization_name "$EMC1413_Channel2_name"
check_customization_name "$TMP468_Channel0_name"
check_customization_name "$TMP468_Channel1_name"
check_customization_name "$TMP468_Channel2_name"
check_customization_name "$TMP468_Channel3_name"
check_customization_name "$TMP468_Channel4_name"
check_customization_name "$TMP468_Channel5_name"
check_customization_name "$TMP468_Channel6_name"
check_customization_name "$TMP468_Channel7_name"
check_customization_name "$TMP468_Channel8_name"
check_customization_name "$TMP112_Sensor_name"
fi
}
set_configuration_5280m7(){
@ -228,11 +270,11 @@ set_configuration_5280m7(){
is_have_pca9641=1
if [ $slot_number -le 2 ];then
pca9641_slave="0x41"
pca9548_slave=0x72
pca9548_slave="0x72"
i2c_bus=12
else
pca9641_slave="0x42"
pca9548_slave=0x72
pca9548_slave="0x72"
i2c_bus=13
fi
fi
@ -245,6 +287,8 @@ set_configuration_5280m7(){
pca9548_channel="0x02"
elif [ $slot_number -eq 2 ];then
pca9548_channel="0x04"
else
format_print $WARNING "Unspecified card slot!"
fi
else
if [ $slot_number -eq 0 ];then
@ -259,6 +303,8 @@ set_configuration_5280m7(){
pca9548_channel="0x04"
elif [ $slot_number -eq 5 ];then
pca9548_channel="0x08"
else
format_print $WARNING "Unspecified card slot!"
fi
fi
}
@ -301,6 +347,8 @@ set_configuration_5468m7(){
pca9548_channel="0x10"
elif [ $slot_number -eq 10 ];then
pca9548_channel="0x20"
else
format_print $WARNING "Unspecified card slot!"
fi
}
@ -326,6 +374,8 @@ set_configuration_donghu(){
pca9548_channel="0x02"
elif [ $slot_number -eq 7 ];then
pca9548_channel="0x01"
else
format_print $WARNING "Unspecified card slot!"
fi
}
@ -344,6 +394,8 @@ set_configuration_yichun(){
elif [ $slot_number -eq 2 ];then
i2c_bus=14
pca9548_channel="0x02"
else
format_print $WARNING "Unspecified card slot!"
fi
}
@ -383,6 +435,8 @@ set_configuration_qiandaohu(){
pca9548_channel="0x01"
elif [ $slot_number -eq 11 ];then
pca9548_channel="0x02"
else
format_print $WARNING "Unspecified card slot!"
fi
}
@ -441,6 +495,7 @@ set_configuration(){
;;
*)
format_print $ERROR "Error: Unsupport Server Type !!! - $server_type"
format_print $INFO "Support list: $Support_Server_List"
exit 1
;;
esac
@ -463,7 +518,7 @@ init_debuglog(){
}
# Before start test, record configurtion to log
prepare_start_info(){
record_config_info(){
format_log_print $INFO "PCIE slot : $nic_slot"
format_log_print $INFO "I2C Bus: $i2c_bus"
@ -1056,7 +1111,7 @@ start_get_sensor(){
if [ $DEBUG_MODE -eq 0 ];then
# set global varible by server type
set_configuration
prepare_start_info
record_config_info
# if we have 9641 on i2c, then do it
if [ $is_have_pca9641 -eq 1 ];then
@ -1091,6 +1146,7 @@ start_get_sensor(){
;;
*)
format_print $ERROR "Unsupport Sensor Type !!! - $sensor_type"
format_print $INFO "Support list: $Support_Sensor_List"
print_usage
;;
esac
@ -1220,7 +1276,8 @@ start_detect_device(){
detect_on_qiandaohu
;;
*)
format_print $ERROR "Unsupport Server Type - $server_type !!!"
format_print $ERROR "Unsupport Server Type - $server_type"
format_print $INFO "Support list : $Support_Server_List"
;;
esac
}