feat(plugin : nicsensor)导入操作执行完毕后默认关闭PCA9548的策略

This commit is contained in:
leimingsheng 2025-05-09 11:43:23 +08:00
parent bba1d037d5
commit 333530ac5a
8 changed files with 48 additions and 1 deletions

@ -100,7 +100,7 @@ connect_i2c(){
start_sensor_reading(){
$fmt_print "log" "Info" "start sensor reading"
$sensor_script "read" "${i2c_bus}" "${chip_slave}" "${server_platform}"
$sensor_script "read" "${i2c_bus}" "${chip_slave}" "${server_platform}" "${server_type}"
}
# ---------------------------------------------------------
# Start Execute Script

@ -141,6 +141,7 @@ detect_on_server(){
do_i2c_detect 3 0x70 0x01 0 0
do_i2c_detect 3 0x70 0x02 1 1
do_i2c_detect 3 0x70 0x04 2 2
i2ctransfer -y 3 w1@0x70 0x00
else
i2c_bus=12
pca9641_slave="0x41"
@ -149,6 +150,7 @@ detect_on_server(){
do_i2c_detect 12 0x72 0x02 1 0
do_i2c_detect 12 0x72 0x04 2 1
do_i2c_detect 12 0x72 0x08 3 2
i2ctransfer -y 12 w1@0x72 0x00
i2c_bus=13
pca9641_slave="0x42"
@ -157,9 +159,14 @@ detect_on_server(){
do_i2c_detect 13 0x72 0x02 1 3
do_i2c_detect 13 0x72 0x04 2 4
do_i2c_detect 13 0x72 0x08 3 5
i2ctransfer -y 13 w1@0x72 0x00
fi
}
reset_all_pca9548(){
$fmt_print "log" "Info" "[platform_5280m7] Bypass reset pca9548"
}
# ---------------------------------------------------
# Start Execute Script
# ---------------------------------------------------
@ -170,6 +177,9 @@ case "${action}" in
"detect")
detect_on_server
;;
"reset")
reset_all_pca9548
;;
*)
$fmt_print "console" "Error" "[platform_5280m7] Unspecified Operation : $action"
exit 1

@ -141,13 +141,21 @@ detect_on_server(){
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
i2ctransfer -y $i2c_bus w1@0x71 0x00
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
i2ctransfer -y $i2c_bus w1@0x72 0x00
fi
}
reset_all_pca9548(){
i2ctransfer -y 12 w1@0x71 0x00
i2ctransfer -y 12 w1@0x72 0x00
}
# ---------------------------------------------------
# Start Execute Script
# ---------------------------------------------------
@ -158,6 +166,9 @@ case "${action}" in
"detect")
detect_on_server
;;
"reset")
reset_all_pca9548
;;
*)
$fmt_print "console" "Error" "[platform_5688m7] Unspecified Operation : $action"
exit 1

@ -24,6 +24,7 @@ mode=$1
i2c_bus=$2
chip_slave=$3
server_platform=$4
server_type=$5
# Only for test purpose
test_data1=$2
@ -33,6 +34,7 @@ test_factor=$4
path=`pwd`
fmt_print="${path}/format_print.sh"
i2c_script="${path}/i2c_${server_platform}.sh"
server_script="${path}/platform_${server_type}.sh"
REG_adc128_config="0x00"
REG_adc128_advance="0x0b"
@ -124,6 +126,9 @@ read_adc128_data(){
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`
# After read option , reset pca9548
$server_script reset
# record i2c raw data to log
$fmt_print "log" "Info" "[plugin_adc128] channel0 : $res_ch0"
$fmt_print "log" "Info" "[plugin_adc128] channel1 : $res_ch1"

@ -4,6 +4,7 @@ mode=$1
i2c_bus=$2
chip_slave=$3
server_platform=$4
server_type=$5
test_data1=$2
test_data2=$3
@ -11,6 +12,7 @@ test_data2=$3
path=`pwd`
fmt_print="${path}/format_print.sh"
i2c_script="${path}/i2c_${server_platform}.sh"
server_script="${path}/platform_${server_type}.sh"
# EMC1413 channel name
EMC1413_Channel0_name="Channel0"
@ -90,6 +92,9 @@ read_emc1413_data(){
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`
# After read option , reset pca9548
$server_script reset
$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"

@ -4,6 +4,7 @@ mode=$1
i2c_bus=$2
chip_slave=$3
server_platform=$4
server_type=$5
test_data1=$2
test_data2=$3
@ -12,6 +13,7 @@ test_resistor=$4
path=`pwd`
fmt_print="${path}/format_print.sh"
i2c_script="${path}/i2c_${server_platform}.sh"
server_script="${path}/platform_${server_type}.sh"
# INA3221 shunt resistor(unit: mohm)
shunt_resistor_0="2"
@ -141,6 +143,9 @@ read_ina3221_data(){
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`
# After read option , reset pca9548
$server_script reset
$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"

@ -4,6 +4,7 @@ mode=$1
i2c_bus=$2
chip_slave=$3
server_platform=$4
server_type=$5
test_data1=$2
test_data2=$3
@ -11,6 +12,7 @@ test_data2=$3
path=`pwd`
fmt_print="${path}/format_print.sh"
i2c_script="${path}/i2c_${server_platform}.sh"
server_script="${path}/platform_${server_type}.sh"
sensor_name="TMP112"
@ -70,6 +72,10 @@ convert_tmp112_data(){
read_tmp112_data(){
res=`$i2c_script $i2c_bus "1" "$chip_slave" "0x00" "2"`
# After read option , reset pca9548
$server_script reset
convert_tmp112_data $res "$sensor_name"
}

@ -4,6 +4,7 @@ mode=$1
i2c_bus=$2
chip_slave=$3
server_platform=$4
server_type=$5
test_data1=$2
test_data2=$3
@ -11,6 +12,7 @@ test_data2=$3
path=`pwd`
fmt_print="${path}/format_print.sh"
i2c_script="${path}/i2c_${server_platform}.sh"
server_script="${path}/platform_${server_type}.sh"
REG_tmp468="0x80"
# TMP468 channel name
@ -70,6 +72,9 @@ convert_tmp468_data(){
read_tmp468_data(){
res_tmp468=`$i2c_script $i2c_bus 1 $chip_slave $REG_tmp468 18`
# After read option , reset pca9548
$server_script reset
$fmt_print "log" "Info" "[plugin_tmp468] Read Raw Data : $res_tmp468"
tmp468_res1_h=`echo $res_tmp468 | awk '{print $1}'`