feat(master : nicsensor) update to 1.9.3

新增支持温度传感器 lm95241
This commit is contained in:
leimingsheng 2026-02-10 13:58:43 +08:00
parent 952f281365
commit 7bb15f6de8

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
SCRIPT_VERSION="1.9.2" SCRIPT_VERSION="1.9.3"
# --------------------------------------------------------- # ---------------------------------------------------------
# Project Feature Varible (Change if need) # Project Feature Varible (Change if need)
# --------------------------------------------------------- # ---------------------------------------------------------
@ -55,13 +55,18 @@ TMP112_Sensor_name="Temperature"
# INA226 channel name # INA226 channel name
INA226_Channel0_name="Channel0" INA226_Channel0_name="Channel0"
# LM95241 channel name
LM95241_Local_name="Local"
LM95241_Remote1_name="Remote1"
LM95241_Remote2_name="Remote2"
# fru basic offset # fru basic offset
fru_offset="0x00 0x00" fru_offset="0x00 0x00"
fru_size=256 fru_size=256
# --------------------------------------------------------- # ---------------------------------------------------------
# Global Settings # 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" Support_Server_List="5280m7, 5468m7, 5688m7, donghu, yichun, qiandaohu"
# Which server will use this script # Which server will use this script
server_type="auto" server_type="auto"
@ -119,6 +124,12 @@ REG_ina226_ch0_current="0x01"
REG_ina226_ch0_voltage="0x02" REG_ina226_ch0_voltage="0x02"
REG_tmp112="0x00" REG_tmp112="0x00"
REG_tmp468="0x80" 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 # Global Param
pca9641_slave=0x41 pca9641_slave=0x41
@ -530,6 +541,7 @@ pre_exec_hook(){
pmbus_op=`$PMBUS_PLUGIN "operation" $str_pmbus_cmd` pmbus_op=`$PMBUS_PLUGIN "operation" $str_pmbus_cmd`
else else
fmt_print "console" $ERROR "Can't find pmbus plugin file, please copy pmbus_cmd_list.sh to here!" fmt_print "console" $ERROR "Can't find pmbus plugin file, please copy pmbus_cmd_list.sh to here!"
exit 1
fi fi
fi fi
@ -1259,6 +1271,70 @@ process_ina226(){
read_ina226_value 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 # CHIP
# --------------------------------------------------------- # ---------------------------------------------------------
# do a customization command # do a customization command
@ -1467,6 +1543,9 @@ start_get_sensor(){
"tmp112") "tmp112")
process_tmp112 process_tmp112
;; ;;
"lm95241")
process_lm95241
;;
"chip") "chip")
process_chip process_chip
;; ;;