Compare commits
2 Commits
625118199f
...
523f597353
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
523f597353 | ||
|
|
72c0ce073e |
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
script_version="v2.0"
|
||||
server_type="5688m7"
|
||||
default_server_type="5688m7"
|
||||
server_platform="m7"
|
||||
|
||||
slot_name=$1
|
||||
@ -11,13 +11,47 @@ param_num=$#
|
||||
|
||||
nic_type=""
|
||||
slot_id=""
|
||||
server_type=""
|
||||
|
||||
path=`pwd`
|
||||
server_script="${path}/platform_${server_type}.sh"
|
||||
sensor_script="${path}/plugin_${sensor_type}.sh"
|
||||
server_script=""
|
||||
sensor_script=""
|
||||
i2c_script="${path}/i2c_${server_platform}.sh"
|
||||
fmt_print="${path}/format_print.sh"
|
||||
|
||||
# According to boardid, parse server_type
|
||||
# Only valid on Gen 7 series
|
||||
try_get_server_type(){
|
||||
if [ -e "/tmp/ns_servertype" ];then
|
||||
server_type=`cat /tmp/ns_servertype`
|
||||
else
|
||||
boardid=`cat /proc/cmdline | awk -F 'boardid=' '{split($2, a," "); print a[1]}'`
|
||||
|
||||
if [ "$boardid" = "" ];then
|
||||
server_type=$default_server_type
|
||||
return
|
||||
fi
|
||||
if [ $boardid -eq 130 ];then
|
||||
server_type="5280m7"
|
||||
elif [ $boardid -eq 150 ];then
|
||||
server_type="5468m7"
|
||||
elif [ $boardid -eq 152 ];then
|
||||
server_type="5688m7"
|
||||
else
|
||||
server_type=$default_server_type
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo $server_type > /tmp/ns_servertype
|
||||
fi
|
||||
}
|
||||
|
||||
script_info_load(){
|
||||
path=`pwd`
|
||||
server_script="${path}/platform_${server_type}.sh"
|
||||
sensor_script="${path}/plugin_${sensor_type}.sh"
|
||||
}
|
||||
|
||||
print_helper(){
|
||||
echo "======>>> nicsensor Scirpt Usage <<<======"
|
||||
echo "Genenral Usage : ./nicsensor.sh [slot] [sensor] [i2c slave]"
|
||||
@ -52,9 +86,12 @@ conf_pre_check(){
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e $sensor_script ];then
|
||||
$fmt_print "console" "Error" "Sensor Script $sensor_script not exist! Maybe unsupport for now!"
|
||||
exit 1
|
||||
# If action is detect , skip this check
|
||||
if [ $param_num -gt 3 ];then
|
||||
if [ ! -e $sensor_script ];then
|
||||
$fmt_print "console" "Error" "Sensor Script $sensor_script not exist! Maybe unsupport for now!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -e $i2c_script ];then
|
||||
@ -102,13 +139,20 @@ start_sensor_reading(){
|
||||
|
||||
$sensor_script "read" "${i2c_bus}" "${chip_slave}" "${server_platform}" "${server_type}"
|
||||
}
|
||||
|
||||
pre_exec_hook(){
|
||||
# init debug log
|
||||
if [ -e "/tmp/nicsensor_debug.log" ];then
|
||||
rm /tmp/nicsensor_debug.log
|
||||
fi
|
||||
try_get_server_type
|
||||
script_info_load
|
||||
conf_pre_check
|
||||
}
|
||||
# ---------------------------------------------------------
|
||||
# Start Execute Script
|
||||
# ---------------------------------------------------------
|
||||
# init debug log
|
||||
if [ -e "/tmp/nicsensor_debug.log" ];then
|
||||
rm /tmp/nicsensor_debug.log
|
||||
fi
|
||||
pre_exec_hook
|
||||
|
||||
# check if is detect option
|
||||
if [ "$1" = "detect" ];then
|
||||
@ -116,8 +160,6 @@ if [ "$1" = "detect" ];then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
conf_pre_check
|
||||
|
||||
parse_slot_name
|
||||
|
||||
i2c_bus=`connect_i2c`
|
||||
|
||||
@ -128,9 +128,9 @@ build_i2c_connect(){
|
||||
# @Param5 pcie slot number
|
||||
do_i2c_detect(){
|
||||
if [ "${nic_type}" == "ocp" ];then
|
||||
$fmt_print "log" "Info" "OCP slot $5 : bus$1 9548channel$4"
|
||||
$fmt_print "console" "Info" "OCP slot $5 : bus$1 9548channel$4"
|
||||
else
|
||||
$fmt_print "log" "Info" "PCIe slot $5 : bus$1 9548channel$4"
|
||||
$fmt_print "console" "Info" "PCIe slot $5 : bus$1 9548channel$4"
|
||||
fi
|
||||
i2ctransfer -y $1 w1@$2 $3
|
||||
i2cdetect -y $1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user