From d3ad01482a32fe33ce4de31e1538f574c6a5f458 Mon Sep 17 00:00:00 2001 From: leimingsheng Date: Sun, 27 Apr 2025 10:21:37 +0800 Subject: [PATCH] =?UTF-8?q?refactor(master=20:=20nicsensor)=20=E6=95=B4?= =?UTF-8?q?=E7=90=86=20=E9=85=8D=E7=BD=AE=E6=A3=80=E6=9F=A5=20=E5=92=8C=20?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E6=97=A5=E5=BF=97=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E4=B8=BA=E5=90=8C=E4=B8=80=E4=B8=AA=E6=8E=A5=E5=8F=A3=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20=E6=96=B0=E6=8E=A5=E5=8F=A3=EF=BC=9Apre=5Fexec=5Fho?= =?UTF-8?q?ok?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nicsensor.sh | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/nicsensor.sh b/nicsensor.sh index 85ed186..2a088a9 100755 --- a/nicsensor.sh +++ b/nicsensor.sh @@ -232,15 +232,6 @@ reset_pca9548(){ i2ctransfer -y $1 w1@$2 0x00 } -# script self test -conf_pre_check(){ - # check DEBUG_MODE value - if [ $DEBUG_MODE -ne 0 ] && [ $DEBUG_MODE -ne 1 ];then - format_print $ERROR "Invalid conf value, DEBUG_MODE: $DEBUG_MODE" - exit 1 - fi -} - set_configuration_5280m7(){ # set pca9641 address && I2C BUS @@ -558,9 +549,13 @@ init_debuglog(){ 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" - if [ $DEBUG_MODE -ne 0 ];then - format_log_print $WARNING "Enable debug mode : $DEBUG_MODE" + if [ $nic_slot == "detect" ];then + format_log_print $INFO "Operation Tpye : i2c detect" + else + format_log_print $INFO "Operation Tpye : read sensor" fi } @@ -615,6 +610,10 @@ switch_pca9548_channel(){ fi } +# pre execute hook function +pre_exec_hook(){ + init_debuglog +} # --------------------------------------------------------- # Chip EMC1413 @@ -1437,7 +1436,7 @@ start_detect_device(){ # Start Execute Script # --------------------------------------------------------- -conf_pre_check +pre_exec_hook if [ "$1" == "version" ];then echo "Script Version : $SCRIPT_VERSION" @@ -1469,8 +1468,6 @@ if [ "$1" == "detect" ];then exit 0 fi -init_debuglog - # if the action is fru write, need pre-process fru data if [ "$sensor_type" == "fru" ];then if [ "$option_data" == "write" ];then