code sync
This commit is contained in:
parent
d71261692d
commit
2b91b4ac61
@ -6,4 +6,15 @@ slave=$3
|
||||
data=$4
|
||||
rc=$5
|
||||
|
||||
i2c_test -b $i2c_bus -s $slave -rc $rc -d $data | awk 'NR==3{for(i=1;i<=NF;i++){printf("0x%s ",$i)}}'
|
||||
path=`pwd`
|
||||
fmt_print="${path}/format_print.sh"
|
||||
|
||||
if [ $rc -eq 0 ];then
|
||||
cmd=`i2c-test -b $i2c_bus -s $slave -w -d $data`
|
||||
else
|
||||
cmd=`i2c-test -b $i2c_bus -s $slave -m 1 -rc $rc -d $data | awk 'NR==2{for(i=1;i<=NF;i++){printf("0x%s ",$i)}}'`
|
||||
fi
|
||||
|
||||
$fmt_print "log" "Info" "[M6 i2c Command]: $cmd"
|
||||
$cmd
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
server_type="5280m7"
|
||||
script_version="v2.0"
|
||||
server_type="5688m7"
|
||||
server_platform="m7"
|
||||
|
||||
slot_name=$1
|
||||
@ -18,8 +19,11 @@ i2c_script="${path}/i2c_${server_platform}.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]"
|
||||
echo "======>>> nicsensor Scirpt Usage <<<======"
|
||||
echo "Genenral Usage : ./nicsensor.sh [slot] [sensor] [i2c slave]"
|
||||
echo "For Detect : ./nicsensor.sh detect [ocp/pcie]"
|
||||
echo "Current Server : $server_type"
|
||||
echo "Script Version : $script_version"
|
||||
}
|
||||
|
||||
perform_detect(){
|
||||
@ -38,11 +42,6 @@ conf_pre_check(){
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 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
|
||||
@ -62,6 +61,12 @@ conf_pre_check(){
|
||||
$fmt_print "console" "Error" "$i2c_script not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
res_date=`date +%Y-%m-%dT%H:%M:%S`
|
||||
$fmt_print "log" "Info" "Start Time : $res_date"
|
||||
$fmt_print "log" "Info" "Script Version : $script_version"
|
||||
$fmt_print "log" "Info" "Server Type : $server_type"
|
||||
$fmt_print "log" "Info" "Slot Name : $slot_name"
|
||||
}
|
||||
|
||||
parse_slot_name(){
|
||||
@ -100,6 +105,11 @@ start_sensor_reading(){
|
||||
# ---------------------------------------------------------
|
||||
# Start Execute Script
|
||||
# ---------------------------------------------------------
|
||||
# init debug log
|
||||
if [ -e "/tmp/nicsensor_debug.log" ];then
|
||||
rm /tmp/nicsensor_debug.log
|
||||
fi
|
||||
|
||||
# check if is detect option
|
||||
if [ "$1" = "detect" ];then
|
||||
perform_detect
|
||||
@ -112,7 +122,7 @@ parse_slot_name
|
||||
|
||||
i2c_bus=`connect_i2c`
|
||||
if [ $? -ne 0 ];then
|
||||
$fmt_print "console" "Error" "An Error occured when build i2c connection with ${slot_name}"
|
||||
$fmt_print "console" "Error" "An Error occured when build i2c connection with ${nic_type} ${slot_id}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ record_i2c_status(){
|
||||
|
||||
set_i2c_config(){
|
||||
# set pca9641 address && I2C BUS
|
||||
if [ "${nic_type}" = "ocp" ];then
|
||||
if [ "${nic_type}" == "ocp" ];then
|
||||
is_have_pca9641=0
|
||||
pca9548_slave="0x70"
|
||||
i2c_bus=3
|
||||
@ -46,7 +46,7 @@ set_i2c_config(){
|
||||
fi
|
||||
|
||||
# set pca9548 switch channel
|
||||
if [ "${nic_type}" = "ocp" ];then
|
||||
if [ "${nic_type}" == "ocp" ];then
|
||||
if [ $slot_id -eq 0 ];then
|
||||
pca9548_channel="0x01"
|
||||
elif [ $slot_id -eq 1 ];then
|
||||
@ -81,14 +81,14 @@ get_pca9641_control(){
|
||||
|
||||
# Request 9641 lock
|
||||
res_lock=`i2ctransfer -y $i2c_bus w2@$pca9641_slave 0x01 0x81 r1`
|
||||
$fmt_print "log" "Info" "[platform_5280m7]After request 9641 lock, The REG value is $res_lock"
|
||||
$fmt_print "log" "Info" "[platform_5280m7] After request 9641 lock, The REG value is $res_lock"
|
||||
|
||||
# Build 9641 Connection
|
||||
res_build=`i2ctransfer -y $i2c_bus w2@$pca9641_slave 0x01 0x85 r1`
|
||||
$fmt_print "log" "Info" "[platform_5280m7]After Build 9641 connection, The REG value is $res_build"
|
||||
$fmt_print "log" "Info" "[platform_5280m7] After Build 9641 connection, The REG value is $res_build"
|
||||
|
||||
if [ "$res_build" != "0x87" ];then
|
||||
$fmt_print "log" "Error" "Cannot establish connection with pca9641 !!!"
|
||||
$fmt_print "console" "Error" "Cannot establish connection with pca9641 !!!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@ -117,7 +117,7 @@ build_i2c_connect(){
|
||||
# @Param4 pca9548 channel
|
||||
# @Param5 pcie slot number
|
||||
do_i2c_detect(){
|
||||
if [ $nic_type == "ocp" ];then
|
||||
if [ "${nic_type}" == "ocp" ];then
|
||||
$fmt_print "log" "Info" "OCP slot $5 : bus$1 9548channel$4"
|
||||
else
|
||||
$fmt_print "log" "Info" "PCIe slot $5 : bus$1 9548channel$4"
|
||||
@ -129,7 +129,7 @@ do_i2c_detect(){
|
||||
detect_on_server(){
|
||||
$fmt_print "console" "Info" "[platform_5280m7] Start i2c detect"
|
||||
|
||||
if [ "${nic_type}" = "ocp" ];then
|
||||
if [ "${nic_type}" == "ocp" ];then
|
||||
i2c_bus=3
|
||||
do_i2c_detect 3 0x70 0x01 0 0
|
||||
do_i2c_detect 3 0x70 0x02 1 1
|
||||
|
||||
161
tool/plugin/platform_5688m7.sh
Normal file
161
tool/plugin/platform_5688m7.sh
Normal file
@ -0,0 +1,161 @@
|
||||
#!/bin/sh
|
||||
|
||||
action=$1
|
||||
nic_type=$2
|
||||
slot_id=$3
|
||||
|
||||
path=`pwd`
|
||||
i2c_script="${path}/i2c_m7.sh"
|
||||
fmt_print="${path}/format_print.sh"
|
||||
|
||||
pca9548_slave=""
|
||||
pca9641_slave=""
|
||||
i2c_bus=""
|
||||
pca9548_channel=""
|
||||
|
||||
is_have_pca9641=0
|
||||
|
||||
record_i2c_status(){
|
||||
$fmt_print "log" "Info" "[platform_5688m7] Start record i2c configuration"
|
||||
$fmt_print "log" "Info" "Nic Type: $nic_type"
|
||||
$fmt_print "log" "Info" "Nic slot: $slot_id"
|
||||
$fmt_print "log" "Info" "i2c bus: $i2c_bus"
|
||||
$fmt_print "log" "Info" "is have pca9641: $is_have_pca9641"
|
||||
$fmt_print "log" "Info" "pca9641 slave: $is_have_pca9641"
|
||||
$fmt_print "log" "Info" "pca9548 slave: $pca9548_slave"
|
||||
$fmt_print "log" "Info" "pca9548 channel: $pca9548_channel"
|
||||
}
|
||||
|
||||
set_i2c_config(){
|
||||
# set pca9641 address && I2C BUS
|
||||
if [ "${nic_type}" == "ocp" ];then
|
||||
$fmt_print "console" "Error" "[platform_5688m7] Unsupport OCP Nic"
|
||||
exit 1
|
||||
else
|
||||
is_have_pca9641=1
|
||||
i2c_bus=12
|
||||
pca9641_slave="0x31"
|
||||
if [ $slot_id -le 3 ];then
|
||||
pca9548_slave="0x71"
|
||||
else
|
||||
pca9548_slave="0x72"
|
||||
fi
|
||||
fi
|
||||
|
||||
# set pca9548 switch channel
|
||||
if [ "${nic_type}" == "ocp" ];then
|
||||
$fmt_print "console" "Error" "[platform_5688m7] Unsupport OCP Nic"
|
||||
exit 1
|
||||
else
|
||||
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"
|
||||
elif [ $slot_id -eq 3 ];then
|
||||
pca9548_channel="0x08"
|
||||
elif [ $slot_id -eq 4 ];then
|
||||
pca9548_channel="0x01"
|
||||
elif [ $slot_id -eq 5 ];then
|
||||
pca9548_channel="0x02"
|
||||
elif [ $slot_id -eq 6 ];then
|
||||
pca9548_channel="0x04"
|
||||
elif [ $slot_id -eq 7 ];then
|
||||
pca9548_channel="0x08"
|
||||
else
|
||||
$fmt_print "console" "Warning" "Unspecified card slot!"
|
||||
fi
|
||||
fi
|
||||
record_i2c_status
|
||||
}
|
||||
|
||||
get_pca9641_control(){
|
||||
$fmt_print "log" "Info" "[platform_5688m7] Start Get pca9641 control"
|
||||
|
||||
# Request 9641 lock
|
||||
res_lock=`i2ctransfer -y $i2c_bus w2@$pca9641_slave 0x01 0x81 r1`
|
||||
$fmt_print "log" "Info" "[platform_5688m7] After request 9641 lock, The REG value is $res_lock"
|
||||
|
||||
# Build 9641 Connection
|
||||
res_build=`i2ctransfer -y $i2c_bus w2@$pca9641_slave 0x01 0x85 r1`
|
||||
$fmt_print "log" "Info" "[platform_5688m7] After Build 9641 connection, The REG value is $res_build"
|
||||
|
||||
if [ "$res_build" != "0x87" ];then
|
||||
$fmt_print "console" "Error" "Cannot establish connection with pca9641 !!!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
select_pca9548_channel(){
|
||||
$fmt_print "log" "Info" "[platform_5688m7] Start Switch PCA9548"
|
||||
$i2c_script "$i2c_bus" 1 "$pca9548_slave" "$pca9548_channel" 0
|
||||
}
|
||||
|
||||
build_i2c_connect(){
|
||||
$fmt_print "log" "Info" "[platform_5688m7] Start build i2c connect"
|
||||
set_i2c_config
|
||||
|
||||
if [ $is_have_pca9641 -eq 1 ];then
|
||||
get_pca9641_control
|
||||
fi
|
||||
|
||||
select_pca9548_channel
|
||||
echo "$i2c_bus"
|
||||
}
|
||||
|
||||
# switch pca9548 channels then do i2cdetect one times
|
||||
# @Param1 i2c bus number
|
||||
# @Param2 pca9548 slave address
|
||||
# @Param3 pca9548 channel hex value
|
||||
# @Param4 pca9548 channel
|
||||
# @Param5 pcie slot number
|
||||
do_i2c_detect(){
|
||||
if [ "${nic_type}" == "ocp" ];then
|
||||
$fmt_print "console" "Info" "OCP slot $5 : bus$1 9548channel$4"
|
||||
else
|
||||
$fmt_print "console" "Info" "PCIe slot $5 : bus$1 9548channel$4"
|
||||
fi
|
||||
i2ctransfer -y $1 w1@$2 $3
|
||||
i2cdetect -y $1
|
||||
}
|
||||
|
||||
detect_on_server(){
|
||||
$fmt_print "console" "Info" "[platform_5688m7] Start i2c detect"
|
||||
|
||||
if [ "${nic_type}" == "ocp" ];then
|
||||
$fmt_print "console" "Error" "[platform_5688m7] Unsupport OCP Nic I2C Detect"
|
||||
else
|
||||
i2c_bus=12
|
||||
pca9641_slave="0x31"
|
||||
get_pca9641_control
|
||||
|
||||
do_i2c_detect $i2c_bus 0x71 0x01 0 0
|
||||
do_i2c_detect $i2c_bus 0x71 0x02 1 1
|
||||
do_i2c_detect $i2c_bus 0x71 0x04 2 2
|
||||
do_i2c_detect $i2c_bus 0x71 0x08 3 3
|
||||
do_i2c_detect $i2c_bus 0x72 0x01 0 4
|
||||
do_i2c_detect $i2c_bus 0x72 0x02 1 5
|
||||
do_i2c_detect $i2c_bus 0x72 0x04 2 6
|
||||
do_i2c_detect $i2c_bus 0x72 0x08 3 7
|
||||
fi
|
||||
}
|
||||
|
||||
# ---------------------------------------------------
|
||||
# Start Execute Script
|
||||
# ---------------------------------------------------
|
||||
case "${action}" in
|
||||
"connect")
|
||||
build_i2c_connect
|
||||
;;
|
||||
"detect")
|
||||
detect_on_server
|
||||
;;
|
||||
*)
|
||||
$fmt_print "console" "Error" "[platform_5688m7] Unspecified Operation : $action"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
@ -1,14 +1,86 @@
|
||||
#!/bin/sh
|
||||
|
||||
# ADC128 Division factor
|
||||
votage_division_factor_0="1"
|
||||
votage_division_factor_1="1"
|
||||
votage_division_factor_2="1"
|
||||
votage_division_factor_3="0.8"
|
||||
votage_division_factor_4="0.6"
|
||||
votage_division_factor_5="0.6"
|
||||
votage_division_factor_6="0.2326"
|
||||
votage_division_factor_7="1"
|
||||
|
||||
# ADC128 channel name
|
||||
ADC128_Channel0_name="Channel0"
|
||||
ADC128_Channel1_name="Channel1"
|
||||
ADC128_Channel2_name="Channel2"
|
||||
ADC128_Channel3_name="Channel3"
|
||||
ADC128_Channel4_name="Channel4"
|
||||
ADC128_Channel5_name="Channel5"
|
||||
ADC128_Channel6_name="Channel6"
|
||||
ADC128_Channel7_name="Channel7"
|
||||
|
||||
mode=$1
|
||||
i2c_bus=$2
|
||||
chip_slave=$3
|
||||
server_platform=$4
|
||||
|
||||
# Only for test purpose
|
||||
test_data1=$2
|
||||
test_data2=$3
|
||||
test_factor=$4
|
||||
|
||||
path=`pwd`
|
||||
fmt_print="${path}/format_print.sh"
|
||||
i2c_script="${path}/i2c_${server_platform}.sh"
|
||||
|
||||
REG_adc128_config="0x00"
|
||||
REG_adc128_advance="0x0b"
|
||||
REG_adc128_status="0x0c"
|
||||
REG_adc128_ch0="0x20"
|
||||
REG_adc128_ch1="0x21"
|
||||
REG_adc128_ch2="0x22"
|
||||
REG_adc128_ch3="0x23"
|
||||
REG_adc128_ch4="0x24"
|
||||
REG_adc128_ch5="0x25"
|
||||
REG_adc128_ch6="0x26"
|
||||
REG_adc128_ch7="0x27"
|
||||
|
||||
print_help(){
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> read"
|
||||
echo " Format : ./plugin_adc128.sh read [i2c-bus] [slave] [platform]"
|
||||
echo " Example: ./plugin_adc128.sh read 13 0x1f m7"
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> test"
|
||||
echo " Format : ./plugin_adc128.sh test [data1] [data2] [factor]"
|
||||
echo " Example: ./plugin_adc128.sh test 0xc7 0x00 0.6"
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> help"
|
||||
echo " Format : ./plugin_adc128.sh help"
|
||||
echo " Example: ./plugin_adc128.sh help"
|
||||
echo "---------------------------------------------------------"
|
||||
}
|
||||
|
||||
# adc128 chip init if need
|
||||
check_adc128_init(){
|
||||
# Get Reg 0x00 status
|
||||
res_adc128_status=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_config 1`
|
||||
# format_log_print $INFO "REG adc128 STATUS : $res_adc128_status"
|
||||
$fmt_print "log" "Info" "[plugin_adc128] REG adc128 STATUS : $res_adc128_status"
|
||||
|
||||
# if stauts is not 0x01 (Start Monitor) ,then do init
|
||||
if [ "$res_adc128_status" != "0x01" ];then
|
||||
$fmt_print "log" "Info" "[plugin_adc128] Start Init ADC128 Chip"
|
||||
# Init ADC128 work as mode 1 (0x02)
|
||||
res_adc128_advance=`$i2c_script $i2c_bus 2 $chip_slave "$REG_adc128_advance 0x02" 0`
|
||||
# Set ADC128 on start (0x01)
|
||||
res_adc128_setstart=`$i2c_script $i2c_bus 2 $chip_slave "$REG_adc128_config 0x01" 1`
|
||||
|
||||
$fmt_print "log" "Info" "[plugin_adc128] After Set status, the REG 0x00 value is $res_adc128_setstart "
|
||||
fi
|
||||
}
|
||||
|
||||
# process sensor data then print to console
|
||||
# @Param 1 adc128 data high 8bit
|
||||
# @Param 2 adc128 data low 8bit
|
||||
@ -40,14 +112,56 @@ convert_adc128_data(){
|
||||
}
|
||||
|
||||
read_adc128_data(){
|
||||
|
||||
# check if chip adc128 need init
|
||||
check_adc128_init
|
||||
|
||||
res_ch0=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch0 2`
|
||||
res_ch1=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch1 2`
|
||||
res_ch2=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch2 2`
|
||||
res_ch3=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch3 2`
|
||||
res_ch4=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch4 2`
|
||||
res_ch5=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch5 2`
|
||||
res_ch6=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch6 2`
|
||||
res_ch7=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch7 2`
|
||||
|
||||
# record i2c raw data to log
|
||||
$fmt_print "log" "Info" "[plugin_adc128] channel0 : $res_ch0"
|
||||
$fmt_print "log" "Info" "[plugin_adc128] channel1 : $res_ch1"
|
||||
$fmt_print "log" "Info" "[plugin_adc128] channel2 : $res_ch2"
|
||||
$fmt_print "log" "Info" "[plugin_adc128] channel3 : $res_ch3"
|
||||
$fmt_print "log" "Info" "[plugin_adc128] channel4 : $res_ch4"
|
||||
$fmt_print "log" "Info" "[plugin_adc128] channel5 : $res_ch5"
|
||||
$fmt_print "log" "Info" "[plugin_adc128] channel6 : $res_ch6"
|
||||
$fmt_print "log" "Info" "[plugin_adc128] channel7 : $res_ch7"
|
||||
|
||||
# start parse raw data
|
||||
$fmt_print "console" "Info" "The ADC128 value is :"
|
||||
convert_adc128_data $res_ch0 "$ADC128_Channel0_name" $votage_division_factor_0
|
||||
convert_adc128_data $res_ch1 "$ADC128_Channel1_name" $votage_division_factor_1
|
||||
convert_adc128_data $res_ch2 "$ADC128_Channel2_name" $votage_division_factor_2
|
||||
convert_adc128_data $res_ch3 "$ADC128_Channel3_name" $votage_division_factor_3
|
||||
convert_adc128_data $res_ch4 "$ADC128_Channel4_name" $votage_division_factor_4
|
||||
convert_adc128_data $res_ch5 "$ADC128_Channel5_name" $votage_division_factor_5
|
||||
convert_adc128_data $res_ch6 "$ADC128_Channel6_name" $votage_division_factor_6
|
||||
convert_adc128_data $res_ch7 "$ADC128_Channel7_name" $votage_division_factor_7
|
||||
}
|
||||
|
||||
test_adc128_value(){
|
||||
convert_adc128_data $test_data1 $test_data2 "Volt" $test_factor
|
||||
}
|
||||
|
||||
case "${mode}" in
|
||||
"read")
|
||||
read_adc128_data
|
||||
;;
|
||||
"test")
|
||||
test_adc128_value
|
||||
;;
|
||||
"help")
|
||||
print_help
|
||||
;;
|
||||
*)
|
||||
$fmt_print "console" "Error" "[plugin_adc128]Unexpected Input Param : $mode"
|
||||
print_help
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
|
||||
@ -5,10 +5,41 @@ i2c_bus=$2
|
||||
chip_slave=$3
|
||||
server_platform=$4
|
||||
|
||||
test_data1=$2
|
||||
test_data2=$3
|
||||
|
||||
path=`pwd`
|
||||
fmt_print="${path}/format_print.sh"
|
||||
i2c_script="${path}/i2c_${server_platform}.sh"
|
||||
|
||||
# EMC1413 channel name
|
||||
EMC1413_Channel0_name="Channel0"
|
||||
EMC1413_Channel1_name="Channel1"
|
||||
EMC1413_Channel2_name="Channel2"
|
||||
|
||||
REG_emc1413_TD1_H="0x00"
|
||||
REG_emc1413_TD1_L="0x29"
|
||||
REG_emc1413_TD2_H="0x01"
|
||||
REG_emc1413_TD2_L="0x10"
|
||||
REG_emc1413_TD3_H="0x23"
|
||||
REG_emc1413_TD3_L="0x24"
|
||||
|
||||
print_help(){
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> read"
|
||||
echo " Format : ./plugin_emc1413.sh read [i2c-bus] [slave] [platform]"
|
||||
echo " Example: ./plugin_emc1413.sh read 13 0x42 m7"
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> test"
|
||||
echo " Format : ./plugin_emc1413.sh test [data1] [data2]"
|
||||
echo " Example: ./plugin_emc1413.sh test 0x24 0x00"
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> help"
|
||||
echo " Format : ./plugin_emc1413.sh help"
|
||||
echo " Example: ./plugin_emc1413.sh help"
|
||||
echo "---------------------------------------------------------"
|
||||
}
|
||||
|
||||
# @Param1 emc1413 data high 8bit
|
||||
# @Param2 emc1413 data low 8bit
|
||||
# @Param3 customization channel name
|
||||
@ -52,14 +83,39 @@ convert_emc1413_data(){
|
||||
}
|
||||
|
||||
read_emc1413_data(){
|
||||
|
||||
res_td1_h=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD1_H 1`
|
||||
res_td1_l=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD1_L 1`
|
||||
res_td2_h=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD2_H 1`
|
||||
res_td2_l=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD2_L 1`
|
||||
res_td3_h=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD3_H 1`
|
||||
res_td3_l=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD3_L 1`
|
||||
|
||||
$fmt_print "log" "Info" "[plugin_emc1413] TD1 : $res_td1_h $res_td1_l"
|
||||
$fmt_print "log" "Info" "[plugin_emc1413] TD2 : $res_td2_h $res_td2_l"
|
||||
$fmt_print "log" "Info" "[plugin_emc1413] TD3 : $res_td3_h $res_td3_l"
|
||||
|
||||
$fmt_print "console" "Info" "The EMC1413 value is :"
|
||||
convert_emc1413_data $res_td1_h $res_td1_l "$EMC1413_Channel0_name"
|
||||
convert_emc1413_data $res_td2_h $res_td2_l "$EMC1413_Channel1_name"
|
||||
convert_emc1413_data $res_td3_h $res_td3_l "$EMC1413_Channel2_name"
|
||||
}
|
||||
|
||||
test_emc1413_data(){
|
||||
convert_emc1413_data $test_data1 $test_data2 "Temp"
|
||||
}
|
||||
|
||||
case "${mode}" in
|
||||
"read")
|
||||
read_emc1413_data
|
||||
;;
|
||||
"test")
|
||||
test_emc1413_data
|
||||
;;
|
||||
"help")
|
||||
print_help
|
||||
;;
|
||||
*)
|
||||
$fmt_print "console" "Error" "[plugin_emc1413]Unexpected Input Param : $mode"
|
||||
print_help
|
||||
;;
|
||||
esac
|
||||
@ -5,10 +5,58 @@ i2c_bus=$2
|
||||
chip_slave=$3
|
||||
server_platform=$4
|
||||
|
||||
test_data1=$2
|
||||
test_data2=$3
|
||||
test_resistor=$4
|
||||
|
||||
path=`pwd`
|
||||
fmt_print="${path}/format_print.sh"
|
||||
i2c_script="${path}/i2c_${server_platform}.sh"
|
||||
|
||||
# INA3221 shunt resistor(unit: mohm)
|
||||
shunt_resistor_0="2"
|
||||
shunt_resistor_1="2"
|
||||
shunt_resistor_2="5"
|
||||
|
||||
# INA3221 channel name
|
||||
INA3221_Channel0_name="Channel0"
|
||||
INA3221_Channel1_name="Channel1"
|
||||
INA3221_Channel2_name="Channel2"
|
||||
|
||||
ina3221_ch0_volt="0"
|
||||
ina3221_ch1_volt="0"
|
||||
ina3221_ch2_volt="0"
|
||||
ina3221_ch0_current="0"
|
||||
ina3221_ch1_current="0"
|
||||
ina3221_ch2_current="0"
|
||||
|
||||
REG_ina3221_ch1="0x01"
|
||||
REG_ina3221_ch2="0x03"
|
||||
REG_ina3221_ch3="0x05"
|
||||
REG_ina3221_bus1="0x02"
|
||||
REG_ina3221_bus2="0x04"
|
||||
REG_ina3221_bus3="0x06"
|
||||
|
||||
INA3221_SHUNT_VOLT=0
|
||||
INA3221_BUS_VOLT=1
|
||||
INA3221_POWER=2
|
||||
|
||||
print_help(){
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> read"
|
||||
echo " Format : ./plugin_ina3221.sh read [i2c-bus] [slave] [platform]"
|
||||
echo " Example: ./plugin_ina3221.sh read 13 0x1f m7"
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> test"
|
||||
echo " Format : ./plugin_ina3221.sh test [data1] [data2] [resistor]"
|
||||
echo " Example: ./plugin_ina3221.sh test 0xc7 0x00 5"
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> help"
|
||||
echo " Format : ./plugin_ina3221.sh help"
|
||||
echo " Example: ./plugin_ina3221.sh help"
|
||||
echo "---------------------------------------------------------"
|
||||
}
|
||||
|
||||
# @Param1 ina3221 data high 8bit
|
||||
# @Param2 ina3221 data high 8bit
|
||||
# @Param3 channel number
|
||||
@ -86,14 +134,50 @@ convert_ina3221_data(){
|
||||
}
|
||||
|
||||
read_ina3221_data(){
|
||||
|
||||
res_ch0=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_ch1 r2`
|
||||
res_ch1=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_ch2 r2`
|
||||
res_ch2=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_ch3 r2`
|
||||
res_bus0=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_bus1 r2`
|
||||
res_bus1=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_bus2 r2`
|
||||
res_bus2=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_bus3 r2`
|
||||
|
||||
$fmt_print "log" "Info" "[plugin_ina3221] channel 0 shunt volt: $res_ch0"
|
||||
$fmt_print "log" "Info" "[plugin_ina3221] channel 1 shunt volt: $res_ch1"
|
||||
$fmt_print "log" "Info" "[plugin_ina3221] channel 2 shunt volt: $res_ch2"
|
||||
$fmt_print "log" "Info" "[plugin_ina3221] channel 0 bus volt: $res_bus0"
|
||||
$fmt_print "log" "Info" "[plugin_ina3221] channel 0 bus volt: $res_bus1"
|
||||
$fmt_print "log" "Info" "[plugin_ina3221] channel 0 bus volt: $res_bus2"
|
||||
|
||||
$fmt_print "console" "Info" "The INA3221 shunt value is :"
|
||||
convert_ina3221_data $res_ch0 0 $INA3221_SHUNT_VOLT $shunt_resistor_0 "$INA3221_Channel0_name"
|
||||
convert_ina3221_data $res_ch1 1 $INA3221_SHUNT_VOLT $shunt_resistor_1 "$INA3221_Channel1_name"
|
||||
convert_ina3221_data $res_ch2 2 $INA3221_SHUNT_VOLT $shunt_resistor_2 "$INA3221_Channel2_name"
|
||||
|
||||
$fmt_print "console" "Info" "The INA3221 bus value is :"
|
||||
convert_ina3221_data $res_bus0 0 $INA3221_BUS_VOLT null "$INA3221_Channel0_name"
|
||||
convert_ina3221_data $res_bus1 1 $INA3221_BUS_VOLT null "$INA3221_Channel1_name"
|
||||
convert_ina3221_data $res_bus2 2 $INA3221_BUS_VOLT null "$INA3221_Channel2_name"
|
||||
|
||||
$fmt_print "console" "Info" "The INA3221 bus power is :"
|
||||
convert_ina3221_data 0 0 0 $INA3221_POWER
|
||||
}
|
||||
|
||||
test_ina3221_value(){
|
||||
convert_ina3221_data $test_data1 $test_data2 0 $INA3221_SHUNT_VOLT $test_resistor "INA3221"
|
||||
}
|
||||
|
||||
case "${mode}" in
|
||||
"read")
|
||||
read_ina3221_data
|
||||
;;
|
||||
"test")
|
||||
test_ina3221_value
|
||||
;;
|
||||
"help")
|
||||
print_help
|
||||
;;
|
||||
*)
|
||||
$fmt_print "console" "Error" "[plugin_ina3221]Unexpected Input Param : $mode"
|
||||
print_help
|
||||
;;
|
||||
esac
|
||||
@ -5,12 +5,31 @@ i2c_bus=$2
|
||||
chip_slave=$3
|
||||
server_platform=$4
|
||||
|
||||
test_data1=$2
|
||||
test_data2=$3
|
||||
|
||||
path=`pwd`
|
||||
fmt_print="${path}/format_print.sh"
|
||||
i2c_script="${path}/i2c_${server_platform}.sh"
|
||||
|
||||
sensor_name="TMP112"
|
||||
|
||||
print_help(){
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> read"
|
||||
echo " Format : ./plugin_tmp112.sh read [i2c-bus] [slave] [platform]"
|
||||
echo " Example: ./plugin_tmp112.sh read 13 0x48 m7"
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> test"
|
||||
echo " Format : ./plugin_tmp112.sh test [data1] [data2]"
|
||||
echo " Example: ./plugin_tmp112.sh test 0x24 0x00"
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> help"
|
||||
echo " Format : ./plugin_tmp112.sh help"
|
||||
echo " Example: ./plugin_tmp112.sh help"
|
||||
echo "---------------------------------------------------------"
|
||||
}
|
||||
|
||||
# @Param1 tmp112 data high 8bit
|
||||
# @Param2 tmp112 data low 8bit
|
||||
# @Param3 customization sensor name
|
||||
@ -43,6 +62,10 @@ convert_tmp112_data(){
|
||||
fi
|
||||
|
||||
echo "$3 : $temp"
|
||||
$fmt_print "log" "Info" "[plugin_tmp112] hex value : ${merge_value}"
|
||||
$fmt_print "log" "Info" "[plugin_tmp112] binary_number : ${binary_number}"
|
||||
$fmt_print "log" "Info" "[plugin_tmp112] bin_length : ${bin_length}"
|
||||
$fmt_print "log" "Info" "[plugin_tmp112] last_digit : ${last_digit}"
|
||||
}
|
||||
|
||||
read_tmp112_data(){
|
||||
@ -50,12 +73,22 @@ read_tmp112_data(){
|
||||
convert_tmp112_data $res "$sensor_name"
|
||||
}
|
||||
|
||||
test_tmp112_data(){
|
||||
convert_tmp112_data $test_data1 $test_data2 "Temp"
|
||||
}
|
||||
|
||||
case "${mode}" in
|
||||
"read")
|
||||
read_tmp112_data
|
||||
;;
|
||||
"test")
|
||||
test_tmp112_data
|
||||
;;
|
||||
"help")
|
||||
print_help
|
||||
;;
|
||||
*)
|
||||
$fmt_print "console" "Error" "[plugin_tmp112]Unexpected Input Param : $mode"
|
||||
$fmt_print "console" "Error" "[plugin_tmp112] Unexpected Input Param : $mode"
|
||||
print_help
|
||||
;;
|
||||
esac
|
||||
|
||||
@ -5,10 +5,42 @@ i2c_bus=$2
|
||||
chip_slave=$3
|
||||
server_platform=$4
|
||||
|
||||
test_data1=$2
|
||||
test_data2=$3
|
||||
|
||||
path=`pwd`
|
||||
fmt_print="${path}/format_print.sh"
|
||||
i2c_script="${path}/i2c_${server_platform}.sh"
|
||||
|
||||
REG_tmp468="0x80"
|
||||
# TMP468 channel name
|
||||
TMP468_Channel0_name="Local"
|
||||
TMP468_Channel1_name="Remote1"
|
||||
TMP468_Channel2_name="Remote2"
|
||||
TMP468_Channel3_name="Remote3"
|
||||
TMP468_Channel4_name="Remote4"
|
||||
TMP468_Channel5_name="Remote5"
|
||||
TMP468_Channel6_name="Remote6"
|
||||
TMP468_Channel7_name="Remote7"
|
||||
TMP468_Channel8_name="Remote8"
|
||||
|
||||
print_help(){
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> read"
|
||||
echo " Format : ./plugin_tmp468.sh read [i2c-bus] [slave] [platform]"
|
||||
echo " Example: ./plugin_tmp468.sh read 13 0x48 m7"
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> test"
|
||||
echo " Format : ./plugin_tmp468.sh test [data1] [data2]"
|
||||
echo " Example: ./plugin_tmp468.sh test 0x24 0x00"
|
||||
echo "---------------------------------------------------------"
|
||||
echo "<option> help"
|
||||
echo " Format : ./plugin_tmp468.sh help"
|
||||
echo " Example: ./plugin_tmp468.sh help"
|
||||
echo "---------------------------------------------------------"
|
||||
}
|
||||
|
||||
|
||||
# @Param1 tmp468 data high 8bit
|
||||
# @Param2 tmp468 data high 8bit
|
||||
# @Param3 customization channel name
|
||||
@ -36,14 +68,57 @@ convert_tmp468_data(){
|
||||
}
|
||||
|
||||
read_tmp468_data(){
|
||||
res_tmp468=`$i2c_script $i2c_bus 1 $chip_slave $REG_tmp468 18`
|
||||
|
||||
$fmt_print "log" "Info" "[plugin_tmp468] Read Raw Data : $res_tmp468"
|
||||
|
||||
tmp468_res1_h=`echo $res_tmp468 | awk '{print $1}'`
|
||||
tmp468_res1_l=`echo $res_tmp468 | awk '{print $2}'`
|
||||
tmp468_res2_h=`echo $res_tmp468 | awk '{print $3}'`
|
||||
tmp468_res2_l=`echo $res_tmp468 | awk '{print $4}'`
|
||||
tmp468_res3_h=`echo $res_tmp468 | awk '{print $5}'`
|
||||
tmp468_res3_l=`echo $res_tmp468 | awk '{print $6}'`
|
||||
tmp468_res4_h=`echo $res_tmp468 | awk '{print $7}'`
|
||||
tmp468_res4_l=`echo $res_tmp468 | awk '{print $8}'`
|
||||
tmp468_res5_h=`echo $res_tmp468 | awk '{print $9}'`
|
||||
tmp468_res5_l=`echo $res_tmp468 | awk '{print $10}'`
|
||||
tmp468_res6_h=`echo $res_tmp468 | awk '{print $11}'`
|
||||
tmp468_res6_l=`echo $res_tmp468 | awk '{print $12}'`
|
||||
tmp468_res7_h=`echo $res_tmp468 | awk '{print $13}'`
|
||||
tmp468_res7_l=`echo $res_tmp468 | awk '{print $14}'`
|
||||
tmp468_res8_h=`echo $res_tmp468 | awk '{print $15}'`
|
||||
tmp468_res8_l=`echo $res_tmp468 | awk '{print $16}'`
|
||||
tmp468_res9_h=`echo $res_tmp468 | awk '{print $17}'`
|
||||
tmp468_res9_l=`echo $res_tmp468 | awk '{print $18}'`
|
||||
|
||||
$fmt_print "console" "Info" "Tmp468 read result:"
|
||||
convert_tmp468_data $tmp468_res1_h $tmp468_res1_l "$TMP468_Channel0_name"
|
||||
convert_tmp468_data $tmp468_res2_h $tmp468_res2_l "$TMP468_Channel1_name"
|
||||
convert_tmp468_data $tmp468_res3_h $tmp468_res3_l "$TMP468_Channel2_name"
|
||||
convert_tmp468_data $tmp468_res4_h $tmp468_res4_l "$TMP468_Channel3_name"
|
||||
convert_tmp468_data $tmp468_res5_h $tmp468_res5_l "$TMP468_Channel4_name"
|
||||
convert_tmp468_data $tmp468_res6_h $tmp468_res6_l "$TMP468_Channel5_name"
|
||||
convert_tmp468_data $tmp468_res7_h $tmp468_res7_l "$TMP468_Channel6_name"
|
||||
convert_tmp468_data $tmp468_res8_h $tmp468_res8_l "$TMP468_Channel7_name"
|
||||
convert_tmp468_data $tmp468_res9_h $tmp468_res9_l "$TMP468_Channel8_name"
|
||||
}
|
||||
|
||||
test_tmp468_data(){
|
||||
convert_tmp468_data $test_data1 $test_data2 "Temp"
|
||||
}
|
||||
|
||||
case "${mode}" in
|
||||
"read")
|
||||
read_tmp468_data
|
||||
;;
|
||||
"test")
|
||||
test_tmp468_data
|
||||
;;
|
||||
"help")
|
||||
print_help
|
||||
;;
|
||||
*)
|
||||
$fmt_print "console" "Error" "[plugin_tmp468]Unexpected Input Param : $mode"
|
||||
$fmt_print "console" "Error" "[plugin_tmp468] Unexpected Input Param : $mode"
|
||||
print_help
|
||||
;;
|
||||
esac
|
||||
Loading…
Reference in New Issue
Block a user