Compare commits

...

5 Commits

2 changed files with 41 additions and 35 deletions

@ -1,9 +1,8 @@
#!/bin/sh
SCRIPT_VERSION="1.7.4"
# ---------------------------------------------------------
# Project Feature Varible (Change as need)
# ---------------------------------------------------------
# ADC128 Division factor
votage_division_factor_0="1"
votage_division_factor_1="1"
@ -55,30 +54,35 @@ TMP112_Sensor_name="Temperature"
# fru basic offset
fru_offset="0x00 0x00"
# ---------------------------------------------------------
# Global Settings
# ---------------------------------------------------------
Support_Sensor_List="emc1413, adc128, ina3221, tmp468, tmp112"
Support_Server_List="5280m7, 5468m7, 5688m7, donghu, yichun, qiandaohu"
# Which server will use this script
server_type="auto"
# DISABLE_DETECT=0 : do i2cdetect when i2c status changed
# =1 : don't do i2cdetect when i2c status changed
DISABLE_DETECT=1
# DEBUG MODE=0 : Disable debug mode
# =1 : Enable debug mode
DEBUG_MODE=0
i2c_bus=12
# ---------------------------------------------------------
# Common Varible (Don't Change)
# Global Varible (Don't Change)
# ---------------------------------------------------------
# Input Param
nic_slot=$1
sensor_type=$2
# Introduction of chip_slave
# 1.chip i2c slave address(7bit)
chip_slave=$3
option_data=$4
option_data2=$5
param_num=$#
# CHIP REGISTER
# REGISTER Table
REG_pca9641_controll="0x01"
REG_adc128_config="0x00"
REG_adc128_advance="0x0b"
REG_adc128_status="0x0c"
@ -90,64 +94,45 @@ REG_adc128_ch4="0x24"
REG_adc128_ch5="0x25"
REG_adc128_ch6="0x26"
REG_adc128_ch7="0x27"
REG_emc1413_TD1_H="0x00"
REG_emc1413_TD1_L="0x29"
REG_emc1413_TD2_H="0x01"
REG_emc1413_TD2_L="0x10"
REG_emc1413_TD3_H="0x23"
REG_emc1413_TD3_L="0x24"
REG_ina3221_ch1="0x01"
REG_ina3221_ch2="0x03"
REG_ina3221_ch3="0x05"
REG_ina3221_bus1="0x02"
REG_ina3221_bus2="0x04"
REG_ina3221_bus3="0x06"
REG_tmp112="0x00"
REG_tmp468="0x80"
# ---------------------------------------------------------
# Global Varible (Don't Change)
# ---------------------------------------------------------
# DISABLE_DETECT=0 : do i2cdetect when i2c status changed
# =1 : don't do i2cdetect when i2c status changed
DISABLE_DETECT=1
# DEBUG MODE=0 : Disable debug mode
# =1 : Enable debug mode
DEBUG_MODE=0
i2c_bus=12
# Global Param
pca9641_slave=0x41
pca9548_channel=0x04
pca9548_slave=0x72
is_have_pca9641=1
log="/tmp/nicsensor_debug.log"
INA3221_SHUNT_VOLT=0
INA3221_BUS_VOLT=1
INA3221_POWER=2
INFO="Info"
WARNING="Warning"
ERROR="Error"
ina3221_ch0_volt="0"
ina3221_ch1_volt="0"
ina3221_ch2_volt="0"
ina3221_ch0_current="0"
ina3221_ch1_current="0"
ina3221_ch2_current="0"
SCRIPT_VERSION="1.7.3"
fru_file_name=$option_data2
fru_write_size=0
fru_write_data=""
nic_type=""
slot_number=""
res_tmp468=""
INFO="Info"
WARNING="Warning"
ERROR="Error"
log="/tmp/nicsensor_debug.log"
# ---------------------------------------------------------
# Script Function Defination
@ -368,7 +353,8 @@ pre_exec_hook(){
init_debuglog
# check server_type if is auto
if [ "$server_type" = "auto" ];then
# if in debug mode, skip this check
if [ "$server_type" = "auto" ] && [ $DEBUG_MODE -eq 0 ];then
try_get_server_type
fi
@ -686,6 +672,9 @@ set_configuration(){
# @Param2 emc1413 data low 8bit
# @Param3 customization channel name
convert_emc1413_data(){
if [ "$3" = "disable" ];then
return
fi
# remove data prefix '0x'
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
@ -784,6 +773,9 @@ check_adc128_init(){
# @Param 3 customization channel name
# @Param 4 division factor
convert_adc128_data(){
if [ "$3" = "disable" ];then
return
fi
# remove data prefix '0x'
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
@ -864,6 +856,9 @@ process_adc128(){
# @Param5 shunt resistor(only used in mode shunt volt)
# @Param6 customization channel name
convert_ina3221_data(){
if [ "$6" = "disable" ];then
return
fi
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
@ -982,6 +977,9 @@ process_ina3221(){
# @Param2 tmp468 data high 8bit
# @Param3 customization channel name
convert_tmp468_data(){
if [ "$3" = "disable" ];then
return
fi
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
merge_value="${hex_value1}${hex_value2}"
@ -1058,6 +1056,10 @@ process_tmp468(){
# @Param2 tmp112 data low 8bit
# @Param3 customization sensor name
convert_tmp112_data(){
if [ "$3" = "disable" ];then
return
fi
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
merge_value="${hex_value1}${hex_value2}"

@ -169,6 +169,10 @@ nicsensor_v2将服务器选通channel和读取传感器数值的功能解耦
### 6_1_Project变量说明
> [!important]
> 对于所有传感器的`xxx_Channel_name`, 将其配置为`disable`即可跳过对应的channel的数据解析。
> 推荐在硬件上空置的Channel将其配置为 `disable`,防止脚本解析数据时出现混淆
**ADC128**相关
- `votage_division_factor_0`: ADC128芯片Channel 0的分压系数
- `votage_division_factor_1`: ADC128芯片Channel 1的分压系数