Compare commits
3 Commits
3301d9fdf7
...
b7671e12e1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7671e12e1 | ||
|
|
c11cd9317a | ||
|
|
d3ad01482a |
83
nicsensor.sh
83
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"
|
||||||
|
|
||||||
@ -138,7 +140,7 @@ ina3221_ch2_volt="0"
|
|||||||
ina3221_ch0_current="0"
|
ina3221_ch0_current="0"
|
||||||
ina3221_ch1_current="0"
|
ina3221_ch1_current="0"
|
||||||
ina3221_ch2_current="0"
|
ina3221_ch2_current="0"
|
||||||
SCRIPT_VERSION="1.6"
|
SCRIPT_VERSION="1.6.1"
|
||||||
|
|
||||||
fru_file_name=$option_data2
|
fru_file_name=$option_data2
|
||||||
fru_write_size=0
|
fru_write_size=0
|
||||||
@ -232,15 +234,6 @@ reset_pca9548(){
|
|||||||
i2ctransfer -y $1 w1@$2 0x00
|
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_configuration_5280m7(){
|
||||||
|
|
||||||
# set pca9641 address && I2C BUS
|
# set pca9641 address && I2C BUS
|
||||||
@ -558,9 +551,15 @@ init_debuglog(){
|
|||||||
res_date=`date +%Y-%m-%dT%H:%M:%S`
|
res_date=`date +%Y-%m-%dT%H:%M:%S`
|
||||||
format_log_print $INFO "Start Time : $res_date"
|
format_log_print $INFO "Start Time : $res_date"
|
||||||
format_log_print $INFO "Script Version : $SCRIPT_VERSION"
|
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
|
if [ "$nic_slot" == "detect" ];then
|
||||||
format_log_print $WARNING "Enable debug mode : $DEBUG_MODE"
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,6 +614,35 @@ switch_pca9548_channel(){
|
|||||||
fi
|
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
|
# Chip EMC1413
|
||||||
@ -1437,7 +1465,7 @@ start_detect_device(){
|
|||||||
# Start Execute Script
|
# Start Execute Script
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
conf_pre_check
|
pre_exec_hook
|
||||||
|
|
||||||
if [ "$1" == "version" ];then
|
if [ "$1" == "version" ];then
|
||||||
echo "Script Version : $SCRIPT_VERSION"
|
echo "Script Version : $SCRIPT_VERSION"
|
||||||
@ -1446,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"
|
||||||
@ -1469,25 +1488,7 @@ if [ "$1" == "detect" ];then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
init_debuglog
|
if [ $param_num -le 2 ];then
|
||||||
|
|
||||||
# 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
|
|
||||||
print_usage
|
print_usage
|
||||||
else
|
else
|
||||||
start_get_sensor
|
start_get_sensor
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user