feat(script : nicsensor.sh)update to version 1.3Intest Rev4

1.增加对tmp468传感器的适配
This commit is contained in:
leimingsheng 2024-12-12 17:27:48 +08:00
parent 5ad98b9226
commit 5510b0d96e

@ -39,6 +39,17 @@ EMC1413_Channel0_name="Channel0"
EMC1413_Channel1_name="Channel1"
EMC1413_Channel2_name="Channel2"
# 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"
# fru basic offset
fru_offset="0x00 0x00"
@ -88,6 +99,8 @@ REG_ina3221_bus1="0x02"
REG_ina3221_bus2="0x04"
REG_ina3221_bus3="0x06"
REG_tmp112="0x00"
REG_tmp468="0x80"
# ---------------------------------------------------------
# Global Varible (Don't Change)
# ---------------------------------------------------------
@ -117,13 +130,14 @@ ina3221_ch2_volt="0"
ina3221_ch0_current="0"
ina3221_ch1_current="0"
ina3221_ch2_current="0"
SCRIPT_VERSION="1.3 Intest Rev3"
SCRIPT_VERSION="1.3 Intest Rev4"
fru_file_name=$option_data2
fru_write_size=0
fru_write_data=""
nic_type=""
slot_number=""
res_tmp468=""
# ---------------------------------------------------------
# Script Function Defination
@ -136,7 +150,7 @@ print_usage(){
echo " Command Format : ./nicsensor.sh [slot] [sensor tpye] [slave]"
echo " Option Detail"
echo " [slot] : 0 1 2 3 4 5 ..."
echo " [sensor type] : emc1413, adc128, ina3221"
echo " [sensor type] : emc1413, adc128, ina3221 tmp468"
echo " [slave] : chip slave address , please provide 7 bit address"
echo " E.G. : ./nicsensor.sh 0 adc128 0x1f"
echo ""
@ -788,7 +802,95 @@ process_ina3221(){
# get chip ina3221 value
read_ina3221_channel_value
}
# ---------------------------------------------------------
# Chip TMP468
# ---------------------------------------------------------
# @Param1 tmp468 data high 8bit
# @Param2 tmp468 data high 8bit
# @Param3 customization channel name
convert_tmp468_data(){
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
merge_value="${hex_value1}${hex_value2}"
# bc calculator recognized upper case only, change data to upper case
upper_hex_value=$(echo "$merge_value" | awk '{
for(i=1; i<=length($0); i++){
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
printf toupper(substr($0,i,1));
else
printf substr($0,i,1);
}
print ""
}')
# change data from hex to dec
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
temp=$(echo "scale=4; $dec_val / 8 * 0.0625" | bc)
echo "$3 : $temp "
}
read_tmp468_value(){
format_log_print $INFO "Start Read tmp468 channel data ..."
res_tmp468=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_tmp468 r18`
format_log_print $INFO "Tmp468 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}'`
format_print $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
}
process_tmp468(){
# tmp112 no need to init firsts
# get chip tmp112 value
read_tmp468_value
}
# ---------------------------------------------------------
# Chip TMP112
# ---------------------------------------------------------
# read_tmp112_value(){
# }
# process_tmp112(){
# # tmp112 no need to init firsts
# # get chip tmp112 value
# read_tmp112_value
# }
# ---------------------------------------------------------
# CHIP
# ---------------------------------------------------------
@ -935,6 +1037,9 @@ start_get_sensor(){
"ina3221")
process_ina3221
;;
"tmp468")
process_tmp468
;;
"chip")
process_chip
;;