Compare commits

...

3 Commits

@ -74,6 +74,8 @@ chip_slave=$3
option_data=$4
option_data2=$5
param_num=$#
# CHIP REGISTER
REG_pca9641_controll="0x01"
@ -138,7 +140,7 @@ ina3221_ch2_volt="0"
ina3221_ch0_current="0"
ina3221_ch1_current="0"
ina3221_ch2_current="0"
SCRIPT_VERSION="1.6"
SCRIPT_VERSION="1.6.1"
fru_file_name=$option_data2
fru_write_size=0
@ -232,15 +234,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 +551,15 @@ 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"
elif [ "$nic_slot" == "version" ];then
format_log_print $INFO "Operation Tpye : get version"
else
format_log_print $INFO "Operation Tpye : read sensor"
fi
}
@ -615,6 +614,35 @@ switch_pca9548_channel(){
fi
}
# pre execute hook function
pre_exec_hook(){
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
}
# ---------------------------------------------------------
# Chip EMC1413
@ -1437,7 +1465,7 @@ start_detect_device(){
# Start Execute Script
# ---------------------------------------------------------
conf_pre_check
pre_exec_hook
if [ "$1" == "version" ];then
echo "Script Version : $SCRIPT_VERSION"
@ -1446,15 +1474,6 @@ if [ "$1" == "version" ];then
exit 0
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 [ "$2" == "ocp" ];then
nic_type="ocp"
@ -1469,25 +1488,7 @@ 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
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
if [ $param_num -le 2 ];then
print_usage
else
start_get_sensor