From 7bb15f6de81befe13109bb31651b07106d145dc8 Mon Sep 17 00:00:00 2001 From: leimingsheng Date: Tue, 10 Feb 2026 13:58:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(master=20:=20nicsensor)=20update=20to=201.?= =?UTF-8?q?9.3=20=E6=96=B0=E5=A2=9E=E6=94=AF=E6=8C=81=E6=B8=A9=E5=BA=A6?= =?UTF-8?q?=E4=BC=A0=E6=84=9F=E5=99=A8=20lm95241?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nicsensor.sh | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 2 deletions(-) diff --git a/nicsensor.sh b/nicsensor.sh index 095a7b6..c038b2f 100755 --- a/nicsensor.sh +++ b/nicsensor.sh @@ -1,5 +1,5 @@ #!/bin/sh -SCRIPT_VERSION="1.9.2" +SCRIPT_VERSION="1.9.3" # --------------------------------------------------------- # Project Feature Varible (Change if need) # --------------------------------------------------------- @@ -55,13 +55,18 @@ TMP112_Sensor_name="Temperature" # INA226 channel name INA226_Channel0_name="Channel0" +# LM95241 channel name +LM95241_Local_name="Local" +LM95241_Remote1_name="Remote1" +LM95241_Remote2_name="Remote2" + # fru basic offset fru_offset="0x00 0x00" fru_size=256 # --------------------------------------------------------- # Global Settings # --------------------------------------------------------- -Support_Sensor_List="emc1413, adc128, ina3221, ina226, tmp468, tmp112" +Support_Sensor_List="emc1413, adc128, ina3221, ina226, tmp468, tmp112, lm95241" Support_Server_List="5280m7, 5468m7, 5688m7, donghu, yichun, qiandaohu" # Which server will use this script server_type="auto" @@ -119,6 +124,12 @@ REG_ina226_ch0_current="0x01" REG_ina226_ch0_voltage="0x02" REG_tmp112="0x00" REG_tmp468="0x80" +REG_lm95241_local_H="0x10" +REG_lm95241_remote1_H="0x11" +REG_lm95241_remote2_H="0x12" +REG_lm95241_local_L="0x20" +REG_lm95241_remote1_L="0x21" +REG_lm95241_remote2_L="0x22" # Global Param pca9641_slave=0x41 @@ -530,6 +541,7 @@ pre_exec_hook(){ pmbus_op=`$PMBUS_PLUGIN "operation" $str_pmbus_cmd` else fmt_print "console" $ERROR "Can't find pmbus plugin file, please copy pmbus_cmd_list.sh to here!" + exit 1 fi fi @@ -1259,6 +1271,70 @@ process_ina226(){ read_ina226_value } # --------------------------------------------------------- +# Chip LM95241 +# --------------------------------------------------------- +# @Param1 lm95241 data high 8bit +# @Param2 lm95241 data low 8bit +# @Param3 customization sensor name +convert_lms95241_data(){ + if [ "$3" = "disable" ];then + return + fi + + hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}') + hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}') + + upper_hex_value1=$(echo "$hex_value1" | 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 "" + }') + dec_val1=$(echo "ibase=16; $upper_hex_value1" | bc) + + upper_hex_value2=$(echo "$hex_value2" | 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 "" + }') + dec_val2=$(echo "ibase=16; $upper_hex_value2" | bc) + + temp=$(echo "scale=4; $dec_val1 + $dec_val2 / 32 * 0.125 " | bc) + + echo "$3 : $temp" +} + +read_lm95241_value(){ + fmt_print "log" $INFO "Start Read LM95241 channel data ..." + res_lm95241_local_h=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_lm95241_local_H r1` + res_lm95241_remote1_h=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_lm95241_remote1_H r1` + res_lm95241_remote2_h=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_lm95241_remote2_H r1` + res_lm95241_local_l=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_lm95241_local_L r1` + res_lm95241_remote1_l=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_lm95241_remote1_L r1` + res_lm95241_remote2_l=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_lm95241_remote2_L r1` + + reset_pca9548 $i2c_bus $pca9548_slave + fmt_print "log" $INFO "LM95241 local data: $res_lm95241_local_h $res_lm95241_local_l" + fmt_print "log" $INFO "LM95241 remote1 data: $res_lm95241_remote1_h $res_lm95241_remote1_l" + fmt_print "log" $INFO "LM95241 remote2 data: $res_lm95241_remote2_h $res_lm95241_remote2_l" + + fmt_print "console" $INFO "LM95241 read result:" + convert_lms95241_data $res_lm95241_local_h $res_lm95241_local_l "$LM95241_Local_name" + convert_lms95241_data $res_lm95241_remote1_h $res_lm95241_remote1_l "$LM95241_Remote1_name" + convert_lms95241_data $res_lm95241_remote2_h $res_lm95241_remote2_l "$LM95241_Remote2_name" +} + +process_lm95241(){ + read_lm95241_value +} +# --------------------------------------------------------- # CHIP # --------------------------------------------------------- # do a customization command @@ -1467,6 +1543,9 @@ start_get_sensor(){ "tmp112") process_tmp112 ;; + "lm95241") + process_lm95241 + ;; "chip") process_chip ;;