refactor(master : nicsensor) 整合fmt_print功能为一个函数

This commit is contained in:
leimingsheng 2025-07-07 16:32:08 +08:00
parent 86e92f0302
commit 85fccf4704

@ -177,18 +177,16 @@ print_usage(){
echo ""
}
# print format message to console
# @Param1 message level [Info Warning Error]
# @Param2 message content
format_print(){
echo ">>> [$1] $2"
}
# print format message to log file
# @Param1 message level [Info Warning Error]
# @Param2 message content
format_log_print(){
echo "[$1] $2" >> $log
# print format message to console|debuglog
# @Param1 direction [console|log], default record to log if invalid
# @Param2 message level [Info Warning Error]
# @Param3 message content
fmt_print(){
if [ "$1" = "console" ];then
echo ">>> [$2] $3"
else
echo "[$2] $3" >> $log
fi
}
# switch pca9548 channels then do i2cdetect one times
@ -199,9 +197,9 @@ format_log_print(){
# @Param5 pcie slot number
do_i2c_detect(){
if [ $nic_type = "ocp" ];then
format_print $INFO "OCP slot $5 : bus$1 9548channel$4"
fmt_print "console" $INFO "OCP slot $5 : bus$1 9548channel$4"
else
format_print $INFO "PCIe slot $5 : bus$1 9548channel$4"
fmt_print "console" $INFO "PCIe slot $5 : bus$1 9548channel$4"
fi
i2ctransfer -y $1 w1@$2 $3
i2cdetect -y $1
@ -240,8 +238,8 @@ parse_nic_slot(){
slot_number=$nic_slot
fi
fi
format_log_print $INFO "Nic Type : $nic_type"
format_log_print $INFO "Slot Num : $slot_number"
fmt_print "log" $INFO "Nic Type : $nic_type"
fmt_print "log" $INFO "Slot Num : $slot_number"
}
# According to boardid, parse server_type
@ -253,8 +251,8 @@ try_get_server_type(){
if [ "$boardid" = "" ];then
server_type="Unknown"
format_print $WARNING "Can't find boardid, auto work failed"
format_print $INFO "Please modify server_type in script manually!"
fmt_print "console" $WARNING "Can't find boardid, auto work failed"
fmt_print "console" $INFO "Please modify server_type in script manually!"
return
fi
if [ $boardid -eq 130 ];then
@ -264,9 +262,9 @@ try_get_server_type(){
elif [ $boardid -eq 152 ];then
server_type="5688m7"
else
format_print $ERROR "Invalid boardid value: $boardid"
format_print $ERROR "Can't specify server type by auto method"
format_print $INFO "Please modify server_type in script manually!"
fmt_print "console" $ERROR "Invalid boardid value: $boardid"
fmt_print "console" $ERROR "Can't specify server type by auto method"
fmt_print "console" $INFO "Please modify server_type in script manually!"
exit 1
fi
@ -280,35 +278,35 @@ init_debuglog(){
fi
res_date=`date +%Y-%m-%dT%H:%M:%S`
format_log_print $INFO "Start Time : $res_date"
format_log_print $INFO "Script Version : $SCRIPT_VERSION"
format_log_print $INFO "Debug Mode : $DEBUG_MODE"
format_log_print $INFO "Disable Detect : $DISABLE_DETECT"
fmt_print "log" $INFO "Start Time : $res_date"
fmt_print "log" $INFO "Script Version : $SCRIPT_VERSION"
fmt_print "log" $INFO "Debug Mode : $DEBUG_MODE"
fmt_print "log" $INFO "Disable Detect : $DISABLE_DETECT"
if [ "$nic_slot" = "detect" ];then
format_log_print $INFO "Operation Type : i2c detect"
fmt_print "log" $INFO "Operation Type : i2c detect"
elif [ "$nic_slot" = "version" ];then
format_log_print $INFO "Operation Type : get version"
fmt_print "log" $INFO "Operation Type : get version"
elif [ $param_num -lt 2 ];then
format_log_print $INFO "Operation Type : help info"
fmt_print "log" $INFO "Operation Type : help info"
else
format_log_print $INFO "Operation Type : read sensor"
fmt_print "log" $INFO "Operation Type : read sensor"
fi
}
# Before start test, record configurtion to log
record_config_info(){
format_log_print $INFO "PCIE slot : $nic_slot"
format_log_print $INFO "I2C Bus: $i2c_bus"
fmt_print "log" $INFO "PCIE slot : $nic_slot"
fmt_print "log" $INFO "I2C Bus: $i2c_bus"
if [ $is_have_pca9641 -eq 1 ];then
format_log_print $INFO "PCA9641 slave: $pca9641_slave"
fmt_print "log" $INFO "PCA9641 slave: $pca9641_slave"
fi
format_log_print $INFO "PCA9548 slave: $pca9548_slave"
format_log_print $INFO "PCA9548 channel: $pca9548_channel"
fmt_print "log" $INFO "PCA9548 slave: $pca9548_slave"
fmt_print "log" $INFO "PCA9548 channel: $pca9548_channel"
# Record i2c device info to log
if [ ${DISABLE_DETECT} -eq 0 ];then
format_log_print $INFO "At the beginning, I2C bus status:"
fmt_print "log" $INFO "At the beginning, I2C bus status:"
i2cdetect -y $i2c_bus >> $log
fi
}
@ -316,11 +314,11 @@ record_config_info(){
get_pca9641_control(){
# Request 9641 lock
res_lock=`i2ctransfer -y $i2c_bus w2@$pca9641_slave $REG_pca9641_controll 0x81 r1`
format_log_print $INFO "After request 9641 lock, The REG value is $res_lock"
fmt_print "log" $INFO "After request 9641 lock, The REG value is $res_lock"
# Build 9641 Connection
res_build=`i2ctransfer -y $i2c_bus w2@$pca9641_slave $REG_pca9641_controll 0x85 r1`
format_log_print $INFO "After Build 9641 connection, The REG value is $res_build"
fmt_print "log" $INFO "After Build 9641 connection, The REG value is $res_build"
# After get 9641 controll, Record i2c device info to log
if [ ${DISABLE_DETECT} -eq 0 ];then
@ -328,7 +326,7 @@ get_pca9641_control(){
fi
if [ "$res_build" != "0x87" ];then
format_print $ERROR "Cannot establish connection with pca9641 !!!"
fmt_print "console" $ERROR "Cannot establish connection with pca9641 !!!"
exit 1
fi
}
@ -336,7 +334,7 @@ get_pca9641_control(){
switch_pca9548_channel(){
# set 9548 channel
res_setchannel=`i2ctransfer -y $i2c_bus w1@$pca9548_slave $pca9548_channel`
format_log_print $INFO "After switch channel"
fmt_print "log" $INFO "After switch channel"
# After set 9548 channel , record i2c device info
if [ ${DISABLE_DETECT} -eq 0 ];then
@ -357,7 +355,7 @@ pre_exec_hook(){
# is param legel?
if [ "$sensor_type" = "chip" ];then
if [ $param_num -le 3 ];then
format_print $ERROR "Command Format illegal"
fmt_print "console" $ERROR "Command Format illegal"
echo "Command Format : ./nicsensor.sh [slot] chip [slave] [i2c_command]"
exit 1
fi
@ -366,11 +364,11 @@ pre_exec_hook(){
# if the action is fru write, need pre-process fru data
if [ "$sensor_type" = "fru" ];then
if [ "$option_data" = "write" ];then
format_log_print $INFO "Opreation FRU Write"
fmt_print "log" $INFO "Opreation FRU Write"
# is option_data(fru file name) valid?
if [ "$option_data2" = "" ];then
format_print $ERROR "Please provide fru file name"
fmt_print "console" $ERROR "Please provide fru file name"
echo "Command Format : ./nicsensor.sh [slot] fru [slave] write [fru_file]"
exit 1
fi
@ -396,7 +394,7 @@ set_configuration_5280m7(){
elif [ $slot_number -eq 2 ];then
pca9548_channel="0x04"
else
format_print $WARNING "Unspecified card slot!"
fmt_print "console" $WARNING "Unspecified card slot!"
fi
else
is_have_pca9641=1
@ -423,15 +421,15 @@ set_configuration_5280m7(){
elif [ $slot_number -eq 5 ];then
pca9548_channel="0x08"
else
format_print $WARNING "Unspecified card slot!"
fmt_print "console" $WARNING "Unspecified card slot!"
fi
fi
}
set_configuration_5468m7(){
if [ $nic_type = "ocp" ];then
format_print $ERROR "Unsupport OCP Nic on $server_type"
format_print $INFO "Please check if script has update version"
fmt_print "console" $ERROR "Unsupport OCP Nic on $server_type"
fmt_print "console" $INFO "Please check if script has update version"
exit 1
else
is_have_pca9641=1
@ -468,15 +466,15 @@ set_configuration_5468m7(){
elif [ $slot_number -eq 10 ];then
pca9548_channel="0x20"
else
format_print $WARNING "Unspecified card slot!"
fmt_print "console" $WARNING "Unspecified card slot!"
fi
fi
}
set_configuration_donghu(){
if [ $nic_type = "ocp" ];then
format_print $ERROR "Unsupport OCP Nic on $server_type"
format_print $INFO "Please check if script has update version"
fmt_print "console" $ERROR "Unsupport OCP Nic on $server_type"
fmt_print "console" $INFO "Please check if script has update version"
exit 1
else
is_have_pca9641=0
@ -499,15 +497,15 @@ set_configuration_donghu(){
elif [ $slot_number -eq 7 ];then
pca9548_channel="0x01"
else
format_print $WARNING "Unspecified card slot!"
fmt_print "console" $WARNING "Unspecified card slot!"
fi
fi
}
set_configuration_yichun(){
if [ $nic_type = "ocp" ];then
format_print $ERROR "Unsupport OCP Nic on $server_type"
format_print $INFO "Please check if script has update version"
fmt_print "console" $ERROR "Unsupport OCP Nic on $server_type"
fmt_print "console" $INFO "Please check if script has update version"
exit 1
else
is_have_pca9641=0
@ -522,15 +520,15 @@ set_configuration_yichun(){
i2c_bus=14
pca9548_channel="0x02"
else
format_print $WARNING "Unspecified card slot!"
fmt_print "console" $WARNING "Unspecified card slot!"
fi
fi
}
set_configuration_qiandaohu(){
if [ $nic_type = "ocp" ];then
format_print $ERROR "Unsupport OCP Nic on $server_type"
format_print $INFO "Please check if script has update version"
fmt_print "console" $ERROR "Unsupport OCP Nic on $server_type"
fmt_print "console" $INFO "Please check if script has update version"
exit 1
else
is_have_pca9641=0
@ -566,15 +564,15 @@ set_configuration_qiandaohu(){
elif [ $slot_number -eq 11 ];then
pca9548_channel="0x02"
else
format_print $WARNING "Unspecified card slot!"
fmt_print "console" $WARNING "Unspecified card slot!"
fi
fi
}
set_configuration_5688m7(){
if [ $nic_type = "ocp" ];then
format_print $ERROR "Unsupport OCP Nic on $server_type"
format_print $INFO "Please check if script has update version"
fmt_print "console" $ERROR "Unsupport OCP Nic on $server_type"
fmt_print "console" $INFO "Please check if script has update version"
exit 1
else
is_have_pca9641=1
@ -602,14 +600,14 @@ set_configuration_5688m7(){
elif [ $slot_number -eq 7 ];then
pca9548_channel="0x08"
else
format_print $WARNING "Unspecified card slot!"
fmt_print "console" $WARNING "Unspecified card slot!"
fi
fi
}
# Base on the server type, set i2c conf
set_configuration(){
format_log_print $INFO "Server Type : $server_type"
fmt_print "log" $INFO "Server Type : $server_type"
parse_nic_slot
case $server_type in
@ -633,8 +631,8 @@ set_configuration(){
set_configuration_5688m7
;;
*)
format_print $ERROR "Error: Unsupport Server Type !!! - $server_type"
format_print $INFO "Support list: $Support_Server_List"
fmt_print "console" $ERROR "Error: Unsupport Server Type !!! - $server_type"
fmt_print "console" $INFO "Support list: $Support_Server_List"
exit 1
;;
esac
@ -685,14 +683,14 @@ convert_emc1413_data(){
# print result to consol
format_temp=$(echo "$temp" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
format_log_print $INFO "$3 - Hex data : $hex_value1 $hex_value2"
fmt_print "log" $INFO "$3 - Hex data : $hex_value1 $hex_value2"
echo "$3 : $format_temp C"
}
# Get the sensor data, then parse raw data
read_emc1413_channel_value(){
format_log_print $INFO "Start EMC1413 channel data ..."
fmt_print "log" $INFO "Start EMC1413 channel data ..."
res_td1_h=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_emc1413_TD1_H r1`
res_td1_l=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_emc1413_TD1_L r1`
@ -703,9 +701,9 @@ read_emc1413_channel_value(){
reset_pca9548 $i2c_bus $pca9548_slave
# record i2c raw data to log
format_log_print $INFO "channel 1 : $res_td1_h $res_td1_l"
format_log_print $INFO "channel 2 : $res_td2_h $res_td2_l"
format_log_print $INFO "channel 3 : $res_td3_h $res_td3_l"
fmt_print "log" $INFO "channel 1 : $res_td1_h $res_td1_l"
fmt_print "log" $INFO "channel 2 : $res_td2_h $res_td2_l"
fmt_print "log" $INFO "channel 3 : $res_td3_h $res_td3_l"
# start parse raw data
echo ">>> The emc1413 value is:"
@ -726,17 +724,17 @@ process_emc1413(){
check_adc128_init(){
# Get Reg 0x00 status
res_adc128_status=`i2cget -y $i2c_bus $chip_slave $REG_adc128_config`
format_log_print $INFO "REG adc128 STATUS : $res_adc128_status"
fmt_print "log" $INFO "REG adc128 STATUS : $res_adc128_status"
# if stauts is not 0x01 (Start Monitor) ,then do init
if [ "$res_adc128_status" != "0x01" ];then
format_log_print $INFO "Start Init ADC128 Chip"
fmt_print "log" $INFO "Start Init ADC128 Chip"
# Init ADC128 work as mode 1 (0x02)
res_adc128_advance=`i2ctransfer -y $i2c_bus w2@$chip_slave $REG_adc128_advance 0x02`
# Set ADC128 on start (0x01)
res_adc128_setstart=`i2ctransfer -y $i2c_bus w2@$chip_slave $REG_adc128_config 0x01 r1`
format_log_print $INFO "After Set status, the REG 0x00 value is $res_adc128_setstart"
fmt_print "log" $INFO "After Set status, the REG 0x00 value is $res_adc128_setstart"
fi
}
@ -770,13 +768,13 @@ convert_adc128_data(){
volt=$(echo "scale=4; $dec_val / 16 / 4096 * 2.65 / $4" | bc)
format_volt=$(echo "$volt" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
format_log_print $INFO "$3 - Hex data: $upper_hex_value"
fmt_print "log" $INFO "$3 - Hex data: $upper_hex_value"
echo "$3 : $format_volt V"
}
# Get the sensor data, then parse raw data
read_adc128_channel_value(){
format_log_print $INFO "Start Read ADC128 channel data ..."
fmt_print "log" $INFO "Start Read ADC128 channel data ..."
res_ch0=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_adc128_ch0 r2`
res_ch1=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_adc128_ch1 r2`
@ -789,14 +787,14 @@ read_adc128_channel_value(){
reset_pca9548 $i2c_bus $pca9548_slave
# record i2c raw data to log
format_log_print $INFO "channel0 : $res_ch0"
format_log_print $INFO "channel1 : $res_ch1"
format_log_print $INFO "channel2 : $res_ch2"
format_log_print $INFO "channel3 : $res_ch3"
format_log_print $INFO "channel4 : $res_ch4"
format_log_print $INFO "channel5 : $res_ch5"
format_log_print $INFO "channel6 : $res_ch6"
format_log_print $INFO "channel7 : $res_ch7"
fmt_print "log" $INFO "channel0 : $res_ch0"
fmt_print "log" $INFO "channel1 : $res_ch1"
fmt_print "log" $INFO "channel2 : $res_ch2"
fmt_print "log" $INFO "channel3 : $res_ch3"
fmt_print "log" $INFO "channel4 : $res_ch4"
fmt_print "log" $INFO "channel5 : $res_ch5"
fmt_print "log" $INFO "channel6 : $res_ch6"
fmt_print "log" $INFO "channel7 : $res_ch7"
# start parse raw data
echo ">>> The ADC128 value is :"
@ -853,7 +851,7 @@ convert_ina3221_data(){
if [ $4 -eq $INA3221_BUS_VOLT ];then
volt=$(echo "scale=4; $dec_val / 8 * 40 / 10000 * 2" | bc)
format_volt=$(echo "$volt" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
format_log_print $INFO "Channel $3 - bus volt - hex value: $upper_hex_value"
fmt_print "log" $INFO "Channel $3 - bus volt - hex value: $upper_hex_value"
echo "$6 : $format_volt V"
if [ $3 -eq 0 ];then
@ -870,7 +868,7 @@ convert_ina3221_data(){
format_current=$(echo "$current" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
format_current_mv=$(echo "$current_mv" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
format_log_print $INFO "Channel $3 - shunt volt - hex value: $upper_hex_value"
fmt_print "log" $INFO "Channel $3 - shunt volt - hex value: $upper_hex_value"
echo "$6 : $format_current A, shunt volt: $format_current_mv mV, shunt resistor: $5 mOhm"
if [ $3 -eq 0 ];then
@ -902,7 +900,7 @@ convert_ina3221_data(){
# Get the sensor data, then parse raw data
read_ina3221_channel_value(){
format_log_print $INFO "Start Read INA3221 channel data ..."
fmt_print "log" $INFO "Start Read INA3221 channel data ..."
res_ch0=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_ina3221_ch1 r2`
res_ch1=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_ina3221_ch2 r2`
@ -913,13 +911,13 @@ read_ina3221_channel_value(){
reset_pca9548 $i2c_bus $pca9548_slave
# record i2c raw data to log
format_log_print $INFO "channel 0 shunt volt: $res_ch0"
format_log_print $INFO "channel 1 shunt volt: $res_ch1"
format_log_print $INFO "channel 2 shunt volt: $res_ch2"
fmt_print "log" $INFO "channel 0 shunt volt: $res_ch0"
fmt_print "log" $INFO "channel 1 shunt volt: $res_ch1"
fmt_print "log" $INFO "channel 2 shunt volt: $res_ch2"
format_log_print $INFO "Channel 0 bus volt : $res_bus0"
format_log_print $INFO "Channel 1 bus volt : $res_bus1"
format_log_print $INFO "Channel 2 bus volt : $res_bus2"
fmt_print "log" $INFO "Channel 0 bus volt : $res_bus0"
fmt_print "log" $INFO "Channel 1 bus volt : $res_bus1"
fmt_print "log" $INFO "Channel 2 bus volt : $res_bus2"
# start parse raw data
echo ">>> The INA3221 shunt value is :"
@ -973,12 +971,12 @@ convert_tmp468_data(){
}
read_tmp468_value(){
format_log_print $INFO "Start Read tmp468 channel data ..."
fmt_print "log" $INFO "Start Read tmp468 channel data ..."
res_tmp468=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_tmp468 r18`
reset_pca9548 $i2c_bus $pca9548_slave
format_log_print $INFO "Tmp468 raw data: $res_tmp468"
fmt_print "log" $INFO "Tmp468 raw data: $res_tmp468"
tmp468_res1_h=`echo $res_tmp468 | awk '{print $1}'`
tmp468_res1_l=`echo $res_tmp468 | awk '{print $2}'`
@ -999,7 +997,7 @@ read_tmp468_value(){
tmp468_res9_h=`echo $res_tmp468 | awk '{print $17}'`
tmp468_res9_l=`echo $res_tmp468 | awk '{print $18}'`
format_print $INFO "Tmp468 read result:"
fmt_print "console" $INFO "Tmp468 read result:"
convert_tmp468_data $tmp468_res1_h $tmp468_res1_l "$TMP468_Channel0_name"
convert_tmp468_data $tmp468_res2_h $tmp468_res2_l "$TMP468_Channel1_name"
convert_tmp468_data $tmp468_res3_h $tmp468_res3_l "$TMP468_Channel2_name"
@ -1054,19 +1052,19 @@ convert_tmp112_data(){
fi
echo "$3 : $temp"
format_log_print $INFO "dec_val : $dec_val"
format_log_print $INFO "binary_number : $binary_number"
format_log_print $INFO "last_digit : $last_digit"
format_log_print $INFO "temp : $temp"
fmt_print "log" $INFO "dec_val : $dec_val"
fmt_print "log" $INFO "binary_number : $binary_number"
fmt_print "log" $INFO "last_digit : $last_digit"
fmt_print "log" $INFO "temp : $temp"
}
read_tmp112_value(){
format_log_print $INFO "Start Read tmp112 channel data ..."
fmt_print "log" $INFO "Start Read tmp112 channel data ..."
res_tmp112=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_tmp112 r2`
reset_pca9548 $i2c_bus $pca9548_slave
format_log_print $INFO "Tmp112 raw data: $res_tmp112"
fmt_print "log" $INFO "Tmp112 raw data: $res_tmp112"
format_print $INFO "Tmp112 read result:"
fmt_print "console" $INFO "Tmp112 read result:"
convert_tmp112_data $res_tmp112 "$TMP112_Sensor_name"
}
@ -1083,8 +1081,8 @@ write_read_chip(){
res_wr=`$cmd_wr`
reset_pca9548 $i2c_bus $pca9548_slave
format_print $INFO "Chip Command: $cmd_wr"
format_print $INFO "The Result : $res_wr"
fmt_print "console" $INFO "Chip Command: $cmd_wr"
fmt_print "console" $INFO "The Result : $res_wr"
}
process_chip(){
@ -1098,18 +1096,18 @@ process_chip(){
# parse fru file to hex string which can be used in i2ctransfer
parse_fru_write_data(){
if [ -e $fru_file_name ];then
format_log_print $INFO "Fru file exist!"
fmt_print "log" $INFO "Fru file exist!"
else
format_log_print $ERROR "Fru file not exist!"
format_print $WARNING "Fru file not exist in current directory!"
format_print $ERROR "Operation Failed!"
fmt_print "log" $ERROR "Fru file not exist!"
fmt_print "console" $WARNING "Fru file not exist in current directory!"
fmt_print "console" $ERROR "Operation Failed!"
exit 1
fi
# calculate fru size
fru_write_size=`ls -lht | grep $fru_file_name | awk '{print $5}'`
format_print $INFO "Fru File [$fru_file_name] size = $fru_write_size Bytes"
format_log_print $INFO "Fru File [$fru_file_name] size = $fru_write_size Bytes"
fmt_print "console" $INFO "Fru File [$fru_file_name] size = $fru_write_size Bytes"
fmt_print "log" $INFO "Fru File [$fru_file_name] size = $fru_write_size Bytes"
# get fru raw data
fru_raw_data=`hexdump -C $fru_file_name | awk '{
@ -1117,7 +1115,7 @@ parse_fru_write_data(){
print $i
}
}'`
format_log_print $INFO "Fru Raw Data: $fru_raw_data"
fmt_print "log" $INFO "Fru Raw Data: $fru_raw_data"
# parse data to hex string
fru_write_data=`echo $fru_raw_data | awk -v size=$fru_write_size '{
@ -1125,7 +1123,7 @@ parse_fru_write_data(){
printf "0x%s ",$i
}
}'`
format_print $INFO "Success to get FRU data"
fmt_print "console" $INFO "Success to get FRU data"
}
read_fru(){
@ -1133,7 +1131,7 @@ read_fru(){
reset_pca9548 $i2c_bus $pca9548_slave
# print fru data every 16 bytes per row
format_print $INFO "The Fru Data :"
fmt_print "console" $INFO "The Fru Data :"
echo "$res_fru" | \
awk '{
line="";
@ -1169,7 +1167,7 @@ write_fru(){
while true
do
if [ $fru_write_size -eq 0 ];then
format_print $INFO "Complete write Fru action!!!"
fmt_print "console" $INFO "Complete write Fru action!!!"
break
fi
@ -1182,13 +1180,13 @@ write_fru(){
}
}
}'`
format_print $INFO "Start write fru data : $once_data"
fmt_print "console" $INFO "Start write fru data : $once_data"
# do once write
hex_num=$(echo "obase=16; $write_offset" | bc)
hex_offset=$(echo $hex_num | awk '{printf("0x%s", $0)}')
write_command="i2ctransfer -y $i2c_bus w10@$chip_slave 0x00 $hex_offset $once_data"
format_log_print $INFO "FRU write command : $write_command"
fmt_print "log" $INFO "FRU write command : $write_command"
write_res=`$write_command`
# counting varible iterate
@ -1211,7 +1209,7 @@ process_fru(){
# This function is temporarily retained for future functional expansion
handle_reserve(){
format_print $INFO "Waiting for user defined"
fmt_print "console" $INFO "Waiting for user defined"
}
# ---------------------------------------------------------
# END of CHIP Function
@ -1259,8 +1257,8 @@ start_get_sensor(){
handle_reserve
;;
*)
format_print $ERROR "Unsupport Sensor Type !!! - $sensor_type"
format_print $INFO "Support list: $Support_Sensor_List"
fmt_print "console" $ERROR "Unsupport Sensor Type !!! - $sensor_type"
fmt_print "console" $INFO "Support list: $Support_Sensor_List"
print_usage
;;
esac
@ -1296,8 +1294,8 @@ detect_on_5280m7(){
detect_on_5468m7(){
if [ $nic_type = "ocp" ];then
format_print $ERROR "Unsupport OCP Nic on $server_type"
format_print $INFO "Please check if script has update version"
fmt_print "console" $ERROR "Unsupport OCP Nic on $server_type"
fmt_print "console" $INFO "Please check if script has update version"
exit 1
fi
@ -1327,8 +1325,8 @@ detect_on_5468m7(){
detect_on_donghu(){
if [ $nic_type = "ocp" ];then
format_print $ERROR "Unsupport OCP Nic on $server_type"
format_print $INFO "Please check if script has update version"
fmt_print "console" $ERROR "Unsupport OCP Nic on $server_type"
fmt_print "console" $INFO "Please check if script has update version"
exit 1
fi
@ -1346,8 +1344,8 @@ detect_on_donghu(){
detect_on_yichun(){
if [ $nic_type = "ocp" ];then
format_print $ERROR "Unsupport OCP Nic on $server_type"
format_print $INFO "Please check if script has update version"
fmt_print "console" $ERROR "Unsupport OCP Nic on $server_type"
fmt_print "console" $INFO "Please check if script has update version"
exit 1
fi
@ -1366,8 +1364,8 @@ detect_on_yichun(){
detect_on_qiandaohu(){
if [ $nic_type = "ocp" ];then
format_print $ERROR "Unsupport OCP Nic on $server_type"
format_print $INFO "Please check if script has update version"
fmt_print "console" $ERROR "Unsupport OCP Nic on $server_type"
fmt_print "console" $INFO "Please check if script has update version"
exit 1
fi
@ -1392,8 +1390,8 @@ detect_on_qiandaohu(){
detect_on_5688m7(){
if [ $nic_type = "ocp" ];then
format_print $ERROR "Unsupport OCP Nic on $server_type"
format_print $INFO "Please check if script has update version"
fmt_print "console" $ERROR "Unsupport OCP Nic on $server_type"
fmt_print "console" $INFO "Please check if script has update version"
exit 1
fi
@ -1415,10 +1413,10 @@ detect_on_5688m7(){
}
debug_user_defined_detect(){
format_print $INFO "Detect by user-defined"
fmt_print "console" $INFO "Detect by user-defined"
# default execute
format_print $INFO "Default detect on the default i2c: $i2c_bus"
fmt_print "console" $INFO "Default detect on the default i2c: $i2c_bus"
i2cdetect -y $i2c_bus
}
@ -1426,12 +1424,12 @@ start_detect_device(){
# In debug mode, do customization detect action
if [ $DEBUG_MODE -ne 0 ];then
format_print $INFO "In debug mode now"
fmt_print "console" $INFO "In debug mode now"
debug_user_defined_detect
exit 0
fi
format_print $INFO "Detect on server : $server_type, nic type: $nic_type"
fmt_print "console" $INFO "Detect on server : $server_type, nic type: $nic_type"
case $server_type in
"5280m7")
detect_on_5280m7
@ -1452,8 +1450,8 @@ start_detect_device(){
detect_on_5688m7
;;
*)
format_print $ERROR "Unsupport Server Type - $server_type"
format_print $INFO "Support list : $Support_Server_List"
fmt_print "console" $ERROR "Unsupport Server Type - $server_type"
fmt_print "console" $INFO "Support list : $Support_Server_List"
;;
esac
}
@ -1473,7 +1471,7 @@ if [ "$1" = "detect" ];then
elif [ "$2" = "pcie" ];then
nic_type="pcie"
else
format_print $WARNING "Please provide valid nic type, default to pcie"
fmt_print "console" $WARNING "Please provide valid nic type, default to pcie"
nic_type="pcie"
fi