refactor(master : nicsensor)将参数校验等功能移入到pre_exec_hook中
This commit is contained in:
parent
d3ad01482a
commit
c11cd9317a
58
nicsensor.sh
58
nicsensor.sh
@ -74,6 +74,8 @@ chip_slave=$3
|
|||||||
option_data=$4
|
option_data=$4
|
||||||
option_data2=$5
|
option_data2=$5
|
||||||
|
|
||||||
|
param_num=$#
|
||||||
|
|
||||||
# CHIP REGISTER
|
# CHIP REGISTER
|
||||||
REG_pca9641_controll="0x01"
|
REG_pca9641_controll="0x01"
|
||||||
|
|
||||||
@ -552,8 +554,10 @@ init_debuglog(){
|
|||||||
format_log_print $INFO "Debug Mode : $DEBUG_MODE"
|
format_log_print $INFO "Debug Mode : $DEBUG_MODE"
|
||||||
format_log_print $INFO "Disable Detect : $DISABLE_DETECT"
|
format_log_print $INFO "Disable Detect : $DISABLE_DETECT"
|
||||||
|
|
||||||
if [ $nic_slot == "detect" ];then
|
if [ "$nic_slot" == "detect" ];then
|
||||||
format_log_print $INFO "Operation Tpye : i2c detect"
|
format_log_print $INFO "Operation Tpye : i2c detect"
|
||||||
|
elif [ "$nic_slot" == "version" ];then
|
||||||
|
format_log_print $INFO "Operation Tpye : get version"
|
||||||
else
|
else
|
||||||
format_log_print $INFO "Operation Tpye : read sensor"
|
format_log_print $INFO "Operation Tpye : read sensor"
|
||||||
fi
|
fi
|
||||||
@ -613,6 +617,31 @@ switch_pca9548_channel(){
|
|||||||
# pre execute hook function
|
# pre execute hook function
|
||||||
pre_exec_hook(){
|
pre_exec_hook(){
|
||||||
init_debuglog
|
init_debuglog
|
||||||
|
|
||||||
|
# is param legel?
|
||||||
|
if [ "$sensor_type" == "chip" ];then
|
||||||
|
if [ $param_num -le 3 ];then
|
||||||
|
format_print $ERROR "Command Format illegal"
|
||||||
|
print_chip_command_format
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
# is option_data(fru file name) valid?
|
||||||
|
if [ "$option_data2" == "" ];then
|
||||||
|
format_print $ERROR "Please provide fru file name"
|
||||||
|
print_fru_command_format
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
parse_fru_write_data
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
@ -1445,15 +1474,6 @@ if [ "$1" == "version" ];then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# is param legel?
|
|
||||||
if [ "$sensor_type" == "chip" ];then
|
|
||||||
if [ $# -le 3 ];then
|
|
||||||
format_print $ERROR "Command Format illegal"
|
|
||||||
print_chip_command_format
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$1" == "detect" ];then
|
if [ "$1" == "detect" ];then
|
||||||
if [ "$2" == "ocp" ];then
|
if [ "$2" == "ocp" ];then
|
||||||
nic_type="ocp"
|
nic_type="ocp"
|
||||||
@ -1468,23 +1488,7 @@ if [ "$1" == "detect" ];then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if the action is fru write, need pre-process fru data
|
if [ $param_num -le 2 ];then
|
||||||
if [ "$sensor_type" == "fru" ];then
|
|
||||||
if [ "$option_data" == "write" ];then
|
|
||||||
format_log_print $INFO "Opreation FRU Write"
|
|
||||||
|
|
||||||
# is option_data(fru file name) valid?
|
|
||||||
if [ "$option_data2" == "" ];then
|
|
||||||
format_print $ERROR "Please provide fru file name"
|
|
||||||
print_fru_command_format
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
parse_fru_write_data
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $# -le 2 ];then
|
|
||||||
print_usage
|
print_usage
|
||||||
else
|
else
|
||||||
start_get_sensor
|
start_get_sensor
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user