Compare commits
No commits in common. "5f4c3ea8ac35e2bd14fe87dda8af76f8883d1c06" and "58f45494af5a602707fde174f5d59a802b74e017" have entirely different histories.
5f4c3ea8ac
...
58f45494af
72
nicsensor.sh
72
nicsensor.sh
@ -1,8 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
SCRIPT_VERSION="1.7.4"
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# Project Feature Varible (Change as need)
|
# Project Feature Varible (Change as need)
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
# ADC128 Division factor
|
# ADC128 Division factor
|
||||||
votage_division_factor_0="1"
|
votage_division_factor_0="1"
|
||||||
votage_division_factor_1="1"
|
votage_division_factor_1="1"
|
||||||
@ -54,35 +55,30 @@ TMP112_Sensor_name="Temperature"
|
|||||||
|
|
||||||
# fru basic offset
|
# fru basic offset
|
||||||
fru_offset="0x00 0x00"
|
fru_offset="0x00 0x00"
|
||||||
# ---------------------------------------------------------
|
|
||||||
# Global Settings
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
Support_Sensor_List="emc1413, adc128, ina3221, tmp468, tmp112"
|
Support_Sensor_List="emc1413, adc128, ina3221, tmp468, tmp112"
|
||||||
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"
|
||||||
|
|
||||||
# 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 Varible (Don't Change)
|
# Common Varible (Don't Change)
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# Input Param
|
# Input Param
|
||||||
nic_slot=$1
|
nic_slot=$1
|
||||||
sensor_type=$2
|
sensor_type=$2
|
||||||
|
|
||||||
|
# Introduction of chip_slave
|
||||||
|
# 1.chip i2c slave address(7bit)
|
||||||
chip_slave=$3
|
chip_slave=$3
|
||||||
option_data=$4
|
option_data=$4
|
||||||
option_data2=$5
|
option_data2=$5
|
||||||
|
|
||||||
param_num=$#
|
param_num=$#
|
||||||
|
|
||||||
# REGISTER Table
|
# CHIP REGISTER
|
||||||
REG_pca9641_controll="0x01"
|
REG_pca9641_controll="0x01"
|
||||||
|
|
||||||
REG_adc128_config="0x00"
|
REG_adc128_config="0x00"
|
||||||
REG_adc128_advance="0x0b"
|
REG_adc128_advance="0x0b"
|
||||||
REG_adc128_status="0x0c"
|
REG_adc128_status="0x0c"
|
||||||
@ -94,45 +90,64 @@ REG_adc128_ch4="0x24"
|
|||||||
REG_adc128_ch5="0x25"
|
REG_adc128_ch5="0x25"
|
||||||
REG_adc128_ch6="0x26"
|
REG_adc128_ch6="0x26"
|
||||||
REG_adc128_ch7="0x27"
|
REG_adc128_ch7="0x27"
|
||||||
|
|
||||||
REG_emc1413_TD1_H="0x00"
|
REG_emc1413_TD1_H="0x00"
|
||||||
REG_emc1413_TD1_L="0x29"
|
REG_emc1413_TD1_L="0x29"
|
||||||
REG_emc1413_TD2_H="0x01"
|
REG_emc1413_TD2_H="0x01"
|
||||||
REG_emc1413_TD2_L="0x10"
|
REG_emc1413_TD2_L="0x10"
|
||||||
REG_emc1413_TD3_H="0x23"
|
REG_emc1413_TD3_H="0x23"
|
||||||
REG_emc1413_TD3_L="0x24"
|
REG_emc1413_TD3_L="0x24"
|
||||||
|
|
||||||
REG_ina3221_ch1="0x01"
|
REG_ina3221_ch1="0x01"
|
||||||
REG_ina3221_ch2="0x03"
|
REG_ina3221_ch2="0x03"
|
||||||
REG_ina3221_ch3="0x05"
|
REG_ina3221_ch3="0x05"
|
||||||
REG_ina3221_bus1="0x02"
|
REG_ina3221_bus1="0x02"
|
||||||
REG_ina3221_bus2="0x04"
|
REG_ina3221_bus2="0x04"
|
||||||
REG_ina3221_bus3="0x06"
|
REG_ina3221_bus3="0x06"
|
||||||
|
|
||||||
REG_tmp112="0x00"
|
REG_tmp112="0x00"
|
||||||
REG_tmp468="0x80"
|
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
|
||||||
|
|
||||||
# Global Param
|
# DEBUG MODE=0 : Disable debug mode
|
||||||
|
# =1 : Enable debug mode
|
||||||
|
DEBUG_MODE=0
|
||||||
|
|
||||||
|
i2c_bus=12
|
||||||
pca9641_slave=0x41
|
pca9641_slave=0x41
|
||||||
pca9548_channel=0x04
|
pca9548_channel=0x04
|
||||||
pca9548_slave=0x72
|
pca9548_slave=0x72
|
||||||
|
|
||||||
is_have_pca9641=1
|
is_have_pca9641=1
|
||||||
|
|
||||||
|
log="/tmp/nicsensor_debug.log"
|
||||||
INA3221_SHUNT_VOLT=0
|
INA3221_SHUNT_VOLT=0
|
||||||
INA3221_BUS_VOLT=1
|
INA3221_BUS_VOLT=1
|
||||||
INA3221_POWER=2
|
INA3221_POWER=2
|
||||||
|
|
||||||
|
INFO="Info"
|
||||||
|
WARNING="Warning"
|
||||||
|
ERROR="Error"
|
||||||
|
|
||||||
ina3221_ch0_volt="0"
|
ina3221_ch0_volt="0"
|
||||||
ina3221_ch1_volt="0"
|
ina3221_ch1_volt="0"
|
||||||
ina3221_ch2_volt="0"
|
ina3221_ch2_volt="0"
|
||||||
ina3221_ch0_current="0"
|
ina3221_ch0_current="0"
|
||||||
ina3221_ch1_current="0"
|
ina3221_ch1_current="0"
|
||||||
ina3221_ch2_current="0"
|
ina3221_ch2_current="0"
|
||||||
|
SCRIPT_VERSION="1.7.3"
|
||||||
|
|
||||||
fru_file_name=$option_data2
|
fru_file_name=$option_data2
|
||||||
fru_write_size=0
|
fru_write_size=0
|
||||||
fru_write_data=""
|
fru_write_data=""
|
||||||
nic_type=""
|
nic_type=""
|
||||||
slot_number=""
|
slot_number=""
|
||||||
res_tmp468=""
|
res_tmp468=""
|
||||||
INFO="Info"
|
|
||||||
WARNING="Warning"
|
|
||||||
ERROR="Error"
|
|
||||||
log="/tmp/nicsensor_debug.log"
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# Script Function Defination
|
# Script Function Defination
|
||||||
@ -353,8 +368,7 @@ pre_exec_hook(){
|
|||||||
init_debuglog
|
init_debuglog
|
||||||
|
|
||||||
# check server_type if is auto
|
# check server_type if is auto
|
||||||
# if in debug mode, skip this check
|
if [ "$server_type" = "auto" ];then
|
||||||
if [ "$server_type" = "auto" ] && [ $DEBUG_MODE -eq 0 ];then
|
|
||||||
try_get_server_type
|
try_get_server_type
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -672,9 +686,6 @@ set_configuration(){
|
|||||||
# @Param2 emc1413 data low 8bit
|
# @Param2 emc1413 data low 8bit
|
||||||
# @Param3 customization channel name
|
# @Param3 customization channel name
|
||||||
convert_emc1413_data(){
|
convert_emc1413_data(){
|
||||||
if [ "$3" = "disable" ];then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
# remove data prefix '0x'
|
# remove data prefix '0x'
|
||||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||||
@ -773,9 +784,6 @@ check_adc128_init(){
|
|||||||
# @Param 3 customization channel name
|
# @Param 3 customization channel name
|
||||||
# @Param 4 division factor
|
# @Param 4 division factor
|
||||||
convert_adc128_data(){
|
convert_adc128_data(){
|
||||||
if [ "$3" = "disable" ];then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
# remove data prefix '0x'
|
# remove data prefix '0x'
|
||||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||||
@ -856,9 +864,6 @@ process_adc128(){
|
|||||||
# @Param5 shunt resistor(only used in mode shunt volt)
|
# @Param5 shunt resistor(only used in mode shunt volt)
|
||||||
# @Param6 customization channel name
|
# @Param6 customization channel name
|
||||||
convert_ina3221_data(){
|
convert_ina3221_data(){
|
||||||
if [ "$6" = "disable" ];then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||||
@ -977,9 +982,6 @@ process_ina3221(){
|
|||||||
# @Param2 tmp468 data high 8bit
|
# @Param2 tmp468 data high 8bit
|
||||||
# @Param3 customization channel name
|
# @Param3 customization channel name
|
||||||
convert_tmp468_data(){
|
convert_tmp468_data(){
|
||||||
if [ "$3" = "disable" ];then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||||
merge_value="${hex_value1}${hex_value2}"
|
merge_value="${hex_value1}${hex_value2}"
|
||||||
@ -1056,10 +1058,6 @@ process_tmp468(){
|
|||||||
# @Param2 tmp112 data low 8bit
|
# @Param2 tmp112 data low 8bit
|
||||||
# @Param3 customization sensor name
|
# @Param3 customization sensor name
|
||||||
convert_tmp112_data(){
|
convert_tmp112_data(){
|
||||||
if [ "$3" = "disable" ];then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||||
merge_value="${hex_value1}${hex_value2}"
|
merge_value="${hex_value1}${hex_value2}"
|
||||||
|
|||||||
@ -169,10 +169,6 @@ nicsensor_v2将服务器选通channel和读取传感器数值的功能解耦,
|
|||||||
|
|
||||||
### 6_1_Project变量说明
|
### 6_1_Project变量说明
|
||||||
|
|
||||||
> [!important]
|
|
||||||
> 对于所有传感器的`xxx_Channel_name`, 将其配置为`disable`即可跳过对应的channel的数据解析。
|
|
||||||
> 推荐在硬件上空置的Channel将其配置为 `disable`,防止脚本解析数据时出现混淆
|
|
||||||
|
|
||||||
**ADC128**相关
|
**ADC128**相关
|
||||||
- `votage_division_factor_0`: ADC128芯片Channel 0的分压系数
|
- `votage_division_factor_0`: ADC128芯片Channel 0的分压系数
|
||||||
- `votage_division_factor_1`: ADC128芯片Channel 1的分压系数
|
- `votage_division_factor_1`: ADC128芯片Channel 1的分压系数
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user