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(){