From 78a17a284317f2177c927f55e0350f8e4d232e8a Mon Sep 17 00:00:00 2001 From: leimingsheng Date: Tue, 31 Dec 2024 10:25:44 +0800 Subject: [PATCH] =?UTF-8?q?fix=20(master=20:=20nicsensor)=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dtmp112=E7=9A=84=E8=AF=BB=E6=95=B0=E6=97=B6=E5=AF=B9?= =?UTF-8?q?=E6=95=B0=E4=BD=8D=E5=8F=96=E5=80=BC=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02.nicsensor/nicsensor.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/02.nicsensor/nicsensor.sh b/02.nicsensor/nicsensor.sh index c9aa22d..03300ca 100644 --- a/02.nicsensor/nicsensor.sh +++ b/02.nicsensor/nicsensor.sh @@ -937,7 +937,8 @@ 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