|
|
|
|
@ -50,6 +50,9 @@ TMP468_Channel6_name="Remote6"
|
|
|
|
|
TMP468_Channel7_name="Remote7"
|
|
|
|
|
TMP468_Channel8_name="Remote8"
|
|
|
|
|
|
|
|
|
|
# TMP112 sensor name
|
|
|
|
|
TMP112_Sensor_name="tmp112"
|
|
|
|
|
|
|
|
|
|
# fru basic offset
|
|
|
|
|
fru_offset="0x00 0x00"
|
|
|
|
|
|
|
|
|
|
@ -130,7 +133,7 @@ ina3221_ch2_volt="0"
|
|
|
|
|
ina3221_ch0_current="0"
|
|
|
|
|
ina3221_ch1_current="0"
|
|
|
|
|
ina3221_ch2_current="0"
|
|
|
|
|
SCRIPT_VERSION="1.3 Intest Rev4"
|
|
|
|
|
SCRIPT_VERSION="1.3 Intest Rev5"
|
|
|
|
|
|
|
|
|
|
fru_file_name=$option_data2
|
|
|
|
|
fru_write_size=0
|
|
|
|
|
@ -150,7 +153,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 tmp468"
|
|
|
|
|
echo " [sensor type] : emc1413, adc128, ina3221, tmp468, tmp112"
|
|
|
|
|
echo " [slave] : chip slave address , please provide 7 bit address"
|
|
|
|
|
echo " E.G. : ./nicsensor.sh 0 adc128 0x1f"
|
|
|
|
|
echo ""
|
|
|
|
|
@ -880,17 +883,54 @@ process_tmp468(){
|
|
|
|
|
# ---------------------------------------------------------
|
|
|
|
|
# Chip TMP112
|
|
|
|
|
# ---------------------------------------------------------
|
|
|
|
|
# @Param1 tmp112 data high 8bit
|
|
|
|
|
# @Param2 tmp112 data low 8bit
|
|
|
|
|
# @Param3 customization sensor name
|
|
|
|
|
convert_tmp112_data(){
|
|
|
|
|
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
|
|
|
|
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
|
|
|
|
merge_value="${hex_value1}${hex_value2}"
|
|
|
|
|
|
|
|
|
|
# read_tmp112_value(){
|
|
|
|
|
|
|
|
|
|
# }
|
|
|
|
|
# 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 ""
|
|
|
|
|
}')
|
|
|
|
|
|
|
|
|
|
# process_tmp112(){
|
|
|
|
|
# # tmp112 no need to init firsts
|
|
|
|
|
# change data from hex to dec
|
|
|
|
|
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
|
|
|
|
|
|
|
|
|
|
# # get chip tmp112 value
|
|
|
|
|
# read_tmp112_value
|
|
|
|
|
# }
|
|
|
|
|
binary_number=$(echo "ibase=16;obase=2;$upper_hex_value" | bc)
|
|
|
|
|
last_digit=$(echo $binary_number | cut -c 16)
|
|
|
|
|
if [ $last_digit -eq 0 ];then
|
|
|
|
|
temp=$(echo "scale=4; $dec_val / 16 * 0.0625" | bc)
|
|
|
|
|
elif [ $last_digit -eq 1];then
|
|
|
|
|
temp=$(echo "scale=4; ( $dec_val - 1 ) / 8 * 0.0625" | bc)
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "$3 : $temp"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
read_tmp112_value(){
|
|
|
|
|
format_log_print $INFO "Start Read tmp112 channel data ..."
|
|
|
|
|
res_tmp112=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_tmp112 r2`
|
|
|
|
|
format_log_print $INFO "Tmp112 raw data: $res_tmp112"
|
|
|
|
|
|
|
|
|
|
format_print $INFO "Tmp112 read result:"
|
|
|
|
|
convert_tmp112_data $res_tmp112 $TMP112_Sensor_name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
process_tmp112(){
|
|
|
|
|
# tmp112 no need to init firsts
|
|
|
|
|
|
|
|
|
|
# get chip tmp112 value
|
|
|
|
|
read_tmp112_value
|
|
|
|
|
}
|
|
|
|
|
# ---------------------------------------------------------
|
|
|
|
|
# CHIP
|
|
|
|
|
# ---------------------------------------------------------
|
|
|
|
|
@ -1040,6 +1080,9 @@ start_get_sensor(){
|
|
|
|
|
"tmp468")
|
|
|
|
|
process_tmp468
|
|
|
|
|
;;
|
|
|
|
|
"tmp112")
|
|
|
|
|
process_tmp112
|
|
|
|
|
;;
|
|
|
|
|
"chip")
|
|
|
|
|
process_chip
|
|
|
|
|
;;
|
|
|
|
|
@ -1047,7 +1090,7 @@ start_get_sensor(){
|
|
|
|
|
process_fru
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
format_print $ERROR "Unsupport Sensor Type !!!"
|
|
|
|
|
format_print $ERROR "Unsupport Sensor Type !!! - $sensor_type"
|
|
|
|
|
print_usage
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|