From 86e92f030294127826da06881aaae6656129f1f4 Mon Sep 17 00:00:00 2001 From: leimingsheng Date: Mon, 7 Jul 2025 16:25:26 +0800 Subject: [PATCH] =?UTF-8?q?style(master=20:=20nicsensor)=20=E7=B2=BE?= =?UTF-8?q?=E7=AE=80=E8=84=9A=E6=9C=AC=E6=B3=A8=E9=87=8A=E5=8F=8A=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nicsensor.sh | 42 ++---------------------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/nicsensor.sh b/nicsensor.sh index 2a17e5c..7a4f27e 100755 --- a/nicsensor.sh +++ b/nicsensor.sh @@ -177,14 +177,6 @@ print_usage(){ echo "" } -print_chip_command_format(){ - echo "Command Format : ./nicsensor.sh [slot] chip [slave] [i2c_command]" -} - -print_fru_command_format(){ - echo "Command Format : ./nicsensor.sh [slot] fru [slave] write [fru_file]" -} - # print format message to console # @Param1 message level [Info Warning Error] # @Param2 message content @@ -283,12 +275,10 @@ try_get_server_type(){ } init_debuglog(){ - # only save one running log if [ -e $log ];then rm $log fi - # print time header 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" @@ -308,7 +298,6 @@ init_debuglog(){ # 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" if [ $is_have_pca9641 -eq 1 ];then @@ -325,7 +314,6 @@ 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" @@ -346,7 +334,6 @@ 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" @@ -371,7 +358,7 @@ pre_exec_hook(){ if [ "$sensor_type" = "chip" ];then if [ $param_num -le 3 ];then format_print $ERROR "Command Format illegal" - print_chip_command_format + echo "Command Format : ./nicsensor.sh [slot] chip [slave] [i2c_command]" exit 1 fi fi @@ -384,7 +371,7 @@ pre_exec_hook(){ # is option_data(fru file name) valid? if [ "$option_data2" = "" ];then format_print $ERROR "Please provide fru file name" - print_fru_command_format + echo "Command Format : ./nicsensor.sh [slot] fru [slave] write [fru_file]" exit 1 fi @@ -397,10 +384,7 @@ pre_exec_hook(){ # Set i2c configuration # --------------------------------------------------------- set_configuration_5280m7(){ - - # set pca9641 address && I2C BUS if [ $nic_type = "ocp" ];then - # Case - OCP is_have_pca9641=0 pca9548_slave="0x70" i2c_bus=3 @@ -415,7 +399,6 @@ set_configuration_5280m7(){ format_print $WARNING "Unspecified card slot!" fi else - # Case - PCIe is_have_pca9641=1 if [ $slot_number -le 2 ];then pca9641_slave="0x41" @@ -447,12 +430,10 @@ set_configuration_5280m7(){ set_configuration_5468m7(){ if [ $nic_type = "ocp" ];then - # Case - OCP format_print $ERROR "Unsupport OCP Nic on $server_type" format_print $INFO "Please check if script has update version" exit 1 else - # Case - PCIe is_have_pca9641=1 if [ $slot_number -le 4 ];then pca9641_slave="0x31" @@ -494,12 +475,10 @@ set_configuration_5468m7(){ set_configuration_donghu(){ if [ $nic_type = "ocp" ];then - # Case - OCP format_print $ERROR "Unsupport OCP Nic on $server_type" format_print $INFO "Please check if script has update version" exit 1 else - # Case - PCIe is_have_pca9641=0 i2c_bus=3 pca9548_slave="0x70" @@ -527,12 +506,10 @@ set_configuration_donghu(){ set_configuration_yichun(){ if [ $nic_type = "ocp" ];then - # Case - OCP format_print $ERROR "Unsupport OCP Nic on $server_type" format_print $INFO "Please check if script has update version" exit 1 else - # Case - PCIe is_have_pca9641=0 pca9548_slave="0x74" if [ $slot_number -eq 0 ];then @@ -552,12 +529,10 @@ set_configuration_yichun(){ set_configuration_qiandaohu(){ if [ $nic_type = "ocp" ];then - # Case - OCP format_print $ERROR "Unsupport OCP Nic on $server_type" format_print $INFO "Please check if script has update version" exit 1 else - # Case - PCIe is_have_pca9641=0 if [ $slot_number -le 7 ];then i2c_bus=3 @@ -598,12 +573,10 @@ set_configuration_qiandaohu(){ set_configuration_5688m7(){ if [ $nic_type = "ocp" ];then - # Case - OCP format_print $ERROR "Unsupport OCP Nic on $server_type" format_print $INFO "Please check if script has update version" exit 1 else - # Case - PCIe is_have_pca9641=1 pca9641_slave="0x31" i2c_bus=12 @@ -636,7 +609,6 @@ set_configuration_5688m7(){ # Base on the server type, set i2c conf set_configuration(){ - format_log_print $INFO "Server Type : $server_type" parse_nic_slot @@ -720,7 +692,6 @@ convert_emc1413_data(){ # Get the sensor data, then parse raw data read_emc1413_channel_value(){ - format_log_print $INFO "Start EMC1413 channel data ..." res_td1_h=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_emc1413_TD1_H r1` @@ -1126,7 +1097,6 @@ 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!" else @@ -1159,7 +1129,6 @@ parse_fru_write_data(){ } read_fru(){ - res_fru=`i2ctransfer -y $i2c_bus w2@$chip_slave $fru_offset r256` reset_pca9548 $i2c_bus $pca9548_slave @@ -1247,9 +1216,7 @@ handle_reserve(){ # --------------------------------------------------------- # END of CHIP Function # --------------------------------------------------------- - start_get_sensor(){ - # switch pca9641 and pca9548 # if enable debug mode, will not do this action. if [ $DEBUG_MODE -eq 0 ];then @@ -1490,20 +1457,16 @@ start_detect_device(){ ;; esac } - # --------------------------------------------------------- # Start Execute Script(main) # --------------------------------------------------------- - pre_exec_hook - if [ "$1" = "version" ];then echo "Script Version : $SCRIPT_VERSION" echo "Debug Mode : $DEBUG_MODE" echo "Disable Detect : $DISABLE_DETECT" exit 0 fi - if [ "$1" = "detect" ];then if [ "$2" = "ocp" ];then nic_type="ocp" @@ -1517,7 +1480,6 @@ if [ "$1" = "detect" ];then start_detect_device exit 0 fi - if [ $param_num -le 2 ];then print_usage else