code sync
This commit is contained in:
parent
f0662a752d
commit
7393c6bfb4
@ -6,8 +6,14 @@ slave=$3
|
|||||||
data=$4
|
data=$4
|
||||||
rc=$5
|
rc=$5
|
||||||
|
|
||||||
|
path=`pwd`
|
||||||
|
fmt_print="${path}/format_print.sh"
|
||||||
|
|
||||||
if [ $rc -eq 0 ];then
|
if [ $rc -eq 0 ];then
|
||||||
i2ctransfer - y $i2c_bus w$wc@$slave $data
|
cmd="i2ctransfer -y $i2c_bus w$wc@$slave $data"
|
||||||
else
|
else
|
||||||
i2ctransfer - y $i2c_bus w$wc@$slave $data r$5
|
cmd="i2ctransfer -y $i2c_bus w$wc@$slave $data r$5"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
$fmt_print "log" "Info" "[M7 i2c Command]: $cmd"
|
||||||
|
$cmd
|
||||||
@ -6,6 +6,7 @@ server_platform="m7"
|
|||||||
slot_name=$1
|
slot_name=$1
|
||||||
sensor_type=$2
|
sensor_type=$2
|
||||||
chip_slave=$3
|
chip_slave=$3
|
||||||
|
param_num=$#
|
||||||
|
|
||||||
nic_type=""
|
nic_type=""
|
||||||
slot_id=""
|
slot_id=""
|
||||||
@ -16,8 +17,18 @@ sensor_script="${path}/plugin_${sensor_type}.sh"
|
|||||||
i2c_script="${path}/i2c_${server_platform}.sh"
|
i2c_script="${path}/i2c_${server_platform}.sh"
|
||||||
fmt_print="${path}/format_print.sh"
|
fmt_print="${path}/format_print.sh"
|
||||||
|
|
||||||
|
print_helper(){
|
||||||
|
echo "Usage : ./nicsensor.sh [slot] [sensor] [i2c slave]"
|
||||||
|
echo "For Detect: ./nicsensor.sh detect [ocp/pcie]"
|
||||||
|
}
|
||||||
|
|
||||||
conf_pre_check(){
|
conf_pre_check(){
|
||||||
|
|
||||||
|
if [ $param_num -lt 1 ];then
|
||||||
|
print_helper
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# init debug log
|
# init debug log
|
||||||
if [ -e "/tmp/nicsensor_debug.log" ];then
|
if [ -e "/tmp/nicsensor_debug.log" ];then
|
||||||
rm /tmp/nicsensor_debug.log
|
rm /tmp/nicsensor_debug.log
|
||||||
@ -29,12 +40,12 @@ conf_pre_check(){
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e $server_script ];then
|
if [ ! -e $server_script ];then
|
||||||
$fmt_print "console" "Error" "$server_script not exist!"
|
$fmt_print "console" "Error" "Server Script $server_script not exist! Maybe unsupport for now!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e $sensor_script ];then
|
if [ ! -e $sensor_script ];then
|
||||||
$fmt_print "console" "Error" "$sensor_script not exist!"
|
$fmt_print "console" "Error" "Sensor Script $sensor_script not exist! Maybe unsupport for now!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -74,6 +85,8 @@ connect_i2c(){
|
|||||||
|
|
||||||
start_sensor_reading(){
|
start_sensor_reading(){
|
||||||
$fmt_print "log" "Info" "start sensor reading"
|
$fmt_print "log" "Info" "start sensor reading"
|
||||||
|
|
||||||
|
$sensor_script "read" "${i2c_bus}" "${chip_slave}" "${server_platform}"
|
||||||
}
|
}
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# Start Execute Script
|
# Start Execute Script
|
||||||
@ -82,7 +95,7 @@ conf_pre_check
|
|||||||
|
|
||||||
parse_slot_name
|
parse_slot_name
|
||||||
|
|
||||||
connect_i2c
|
i2c_bus=`connect_i2c`
|
||||||
|
|
||||||
start_sensor_reading
|
start_sensor_reading
|
||||||
|
|
||||||
|
|||||||
@ -81,7 +81,7 @@ get_pca9641_control(){
|
|||||||
|
|
||||||
select_pca9548_channel(){
|
select_pca9548_channel(){
|
||||||
$fmt_print "log" "Info" "[platform_5280m7] Start Switch PCA9548"
|
$fmt_print "log" "Info" "[platform_5280m7] Start Switch PCA9548"
|
||||||
# $i2c_script "$i2c_bus" 1 "$pca9548_slave" "$pca9548_channel" 0
|
$i2c_script "$i2c_bus" 1 "$pca9548_slave" "$pca9548_channel" 0
|
||||||
}
|
}
|
||||||
|
|
||||||
build_i2c_connect(){
|
build_i2c_connect(){
|
||||||
|
|||||||
@ -1,5 +1,16 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
mode=$1
|
||||||
|
i2c_bus=$2
|
||||||
|
chip_slave=$3
|
||||||
|
server_platform=$4
|
||||||
|
|
||||||
|
path=`pwd`
|
||||||
|
fmt_print="${path}/format_print.sh"
|
||||||
|
i2c_script="${path}/i2c_${server_platform}.sh"
|
||||||
|
|
||||||
|
sensor_name="TMP112"
|
||||||
|
|
||||||
# @Param1 tmp112 data high 8bit
|
# @Param1 tmp112 data high 8bit
|
||||||
# @Param2 tmp112 data low 8bit
|
# @Param2 tmp112 data low 8bit
|
||||||
# @Param3 customization sensor name
|
# @Param3 customization sensor name
|
||||||
@ -34,5 +45,17 @@ convert_tmp112_data(){
|
|||||||
echo "$3 : $temp"
|
echo "$3 : $temp"
|
||||||
}
|
}
|
||||||
|
|
||||||
# E.G. ./plugin_tmp112.sh 0x08 0x40 temp
|
read_tmp112_data(){
|
||||||
convert_tmp112_data $1 $2 $3
|
res=`$i2c_script $i2c_bus "1" "$chip_slave" "0x00" "2"`
|
||||||
|
convert_tmp112_data $res "$sensor_name"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case "${mode}" in
|
||||||
|
"read")
|
||||||
|
read_tmp112_data
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
$fmt_print "console" "Error" "[plugin_tmp112]Unexpected Input Param : $mode"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user