code sync
This commit is contained in:
parent
73d92cbb61
commit
0b3f79b1af
19
tool/plugin/format_print.sh
Normal file
19
tool/plugin/format_print.sh
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
logfile="/tmp/nicsensor_debug.log"
|
||||||
|
|
||||||
|
direction=$1
|
||||||
|
level=$2
|
||||||
|
content=$3
|
||||||
|
|
||||||
|
case "${direction}" in
|
||||||
|
"console")
|
||||||
|
echo ">>> [$level] : $content"
|
||||||
|
;;
|
||||||
|
"log")
|
||||||
|
echo "[$level] : $content" >> $logfile
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Error In format_print.sh! Param : $direction"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
88
tool/plugin/nicsensor.sh
Normal file
88
tool/plugin/nicsensor.sh
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
server_type="5280m7"
|
||||||
|
server_platform="m7"
|
||||||
|
|
||||||
|
slot_name=$1
|
||||||
|
sensor_type=$2
|
||||||
|
chip_slave=$3
|
||||||
|
|
||||||
|
nic_type=""
|
||||||
|
slot_id=""
|
||||||
|
|
||||||
|
server_script="platform_${server_type}.sh"
|
||||||
|
sensor_script="plugin_${sensor_type}.sh"
|
||||||
|
i2c_script="i2c_${server_platform}.sh"
|
||||||
|
fmt_print="format_print.sh"
|
||||||
|
|
||||||
|
conf_pre_check(){
|
||||||
|
|
||||||
|
# init debug log
|
||||||
|
if [ -e "/tmp/nicsensor_debug.log" ];then
|
||||||
|
rm /tmp/nicsensor_debug.log
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e $fmt_print ];then
|
||||||
|
echo "Missing file $fmt_print !!!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e $server_script ];then
|
||||||
|
$fmt_print "console" "Error" "$server_script not exist!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e $sensor_script ];then
|
||||||
|
$fmt_print "console" "Error" "$sensor_script not exist!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e $i2c_script ];then
|
||||||
|
$fmt_print "console" "Error" "$i2c_script not exist!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_slot_name(){
|
||||||
|
# Get nic type and slot id from slot name
|
||||||
|
case "{$slot_name}" in
|
||||||
|
ocp*)
|
||||||
|
nic_type="ocp"
|
||||||
|
slot_id=`echo $slot_name | cut -c 4`
|
||||||
|
;;
|
||||||
|
pcie*)
|
||||||
|
nic_type="pcie"
|
||||||
|
slot_id=`echo $slot_name | cut -c 5-`
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
$fmt_print "log" "Warning" "Undetermined nic type, default set to pcie"
|
||||||
|
nic_type="pcie"
|
||||||
|
slot_id=$slot_name
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
connect_i2c(){
|
||||||
|
$server_script "connect" "$nic_type" "$slot_id"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ];then
|
||||||
|
$fmt_print "console" "Error" "Can't build i2c connection"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
start_sensor_reading(){
|
||||||
|
|
||||||
|
}
|
||||||
|
# ---------------------------------------------------------
|
||||||
|
# Start Execute Script
|
||||||
|
# ---------------------------------------------------------
|
||||||
|
conf_pre_check
|
||||||
|
|
||||||
|
parse_slot_name
|
||||||
|
|
||||||
|
connect_i2c
|
||||||
|
|
||||||
|
start_sensor_reading
|
||||||
|
|
||||||
|
|
||||||
88
tool/plugin/platform_5280m7.sh
Normal file
88
tool/plugin/platform_5280m7.sh
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
action=$1
|
||||||
|
nic_type=$2
|
||||||
|
slot_id=$3
|
||||||
|
|
||||||
|
i2c_script="i2c_m7.sh"
|
||||||
|
fmt_print="format_print.sh"
|
||||||
|
|
||||||
|
pca9548_slave=""
|
||||||
|
pca9641_slave=""
|
||||||
|
i2c_bus=""
|
||||||
|
pca9548_channel=""
|
||||||
|
|
||||||
|
set_i2c_config(){
|
||||||
|
# set pca9641 address && I2C BUS
|
||||||
|
if [ $nic_type == "ocp" ];then
|
||||||
|
pca9548_slave="0x70"
|
||||||
|
i2c_bus=3
|
||||||
|
else
|
||||||
|
if [ $slot_id -le 2 ];then
|
||||||
|
pca9641_slave="0x41"
|
||||||
|
pca9548_slave="0x72"
|
||||||
|
i2c_bus=12
|
||||||
|
else
|
||||||
|
pca9641_slave="0x42"
|
||||||
|
pca9548_slave="0x72"
|
||||||
|
i2c_bus=13
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set pca9548 switch channel
|
||||||
|
if [ $nic_type == "ocp" ];then
|
||||||
|
if [ $slot_id -eq 0 ];then
|
||||||
|
pca9548_channel="0x01"
|
||||||
|
elif [ $slot_id -eq 1 ];then
|
||||||
|
pca9548_channel="0x02"
|
||||||
|
elif [ $slot_id -eq 2 ];then
|
||||||
|
pca9548_channel="0x04"
|
||||||
|
else
|
||||||
|
$fmt_print "console" "Warning" "Unspecified card slot!"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ $slot_id -eq 0 ];then
|
||||||
|
pca9548_channel="0x02"
|
||||||
|
elif [ $slot_id -eq 1 ];then
|
||||||
|
pca9548_channel="0x04"
|
||||||
|
elif [ $slot_id -eq 2 ];then
|
||||||
|
pca9548_channel="0x08"
|
||||||
|
elif [ $slot_id -eq 3 ];then
|
||||||
|
pca9548_channel="0x02"
|
||||||
|
elif [ $slot_id -eq 4 ];then
|
||||||
|
pca9548_channel="0x04"
|
||||||
|
elif [ $slot_id -eq 5 ];then
|
||||||
|
pca9548_channel="0x08"
|
||||||
|
else
|
||||||
|
$fmt_print "console" "Warning" "Unspecified card slot!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
build_i2c_connect(){
|
||||||
|
$fmt_print "log" "Info" "[platform_5280m7] Start build i2c connect"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
detect_on_server(){
|
||||||
|
$fmt_print "log" "Info" "[platform_5280m7] Start i2c detect"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ---------------------------------------------------
|
||||||
|
# Start Execute Script
|
||||||
|
# ---------------------------------------------------
|
||||||
|
case "${action}" in
|
||||||
|
"connect")
|
||||||
|
build_i2c_connect
|
||||||
|
;;
|
||||||
|
"detect")
|
||||||
|
detect_on_server
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
$fmt_print "console" "Error" "[platform_5280m7] Unspecified Operation : $action"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user