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

@ -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
@ -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