fix(master : nicsensor)修复tmp112的数值读取功能
This commit is contained in:
parent
1fbb99bb83
commit
b8f2c88020
@ -937,14 +937,19 @@ convert_tmp112_data(){
|
|||||||
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
|
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
|
||||||
|
|
||||||
binary_number=$(echo "ibase=16;obase=2;$upper_hex_value" | bc)
|
binary_number=$(echo "ibase=16;obase=2;$upper_hex_value" | bc)
|
||||||
last_digit=$(echo $binary_number | cut -c 16)
|
bin_length=$(echo $binary_number | awk '{print length($0)}')
|
||||||
|
last_digit=$(echo $binary_number | cut -c $bin_length)
|
||||||
if [ $last_digit -eq 0 ];then
|
if [ $last_digit -eq 0 ];then
|
||||||
temp=$(echo "scale=4; $dec_val / 16 * 0.0625" | bc)
|
temp=$(echo "scale=4; $dec_val / 16 * 0.0625" | bc)
|
||||||
elif [ $last_digit -eq 1];then
|
elif [ $last_digit -eq 1 ];then
|
||||||
temp=$(echo "scale=4; ( $dec_val - 1 ) / 8 * 0.0625" | bc)
|
temp=$(echo "scale=4; ( $dec_val - 1 ) / 8 * 0.0625" | bc)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$3 : $temp"
|
echo "$3 : $temp"
|
||||||
|
format_log_print $INFO "dec_val : $dec_val"
|
||||||
|
format_log_print $INFO "binary_number : $binary_number"
|
||||||
|
format_log_print $INFO "last_digit : $last_digit"
|
||||||
|
format_log_print $INFO "temp : $temp"
|
||||||
}
|
}
|
||||||
|
|
||||||
read_tmp112_value(){
|
read_tmp112_value(){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user