From b8f2c880203312ceb8e8e75841112fe6e1f24842 Mon Sep 17 00:00:00 2001 From: leimingsheng Date: Tue, 31 Dec 2024 10:30:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(master=20:=20nicsensor)=E4=BF=AE=E5=A4=8Dtm?= =?UTF-8?q?p112=E7=9A=84=E6=95=B0=E5=80=BC=E8=AF=BB=E5=8F=96=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nicsensor.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nicsensor.sh b/nicsensor.sh index 85b3070..981caec 100755 --- a/nicsensor.sh +++ b/nicsensor.sh @@ -937,14 +937,19 @@ convert_tmp112_data(){ dec_val=$(echo "ibase=16; $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 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) fi 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(){