Compare commits

..

4 Commits

2 changed files with 112 additions and 21 deletions

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
SCRIPT_VERSION="1.7.6" SCRIPT_VERSION="1.7.7"
# --------------------------------------------------------- # ---------------------------------------------------------
# Project Feature Varible (Change as need) # Project Feature Varible (Change as need)
# --------------------------------------------------------- # ---------------------------------------------------------
@ -81,6 +81,11 @@ option_data=$4
option_data2=$5 option_data2=$5
param_num=$# param_num=$#
# Param alias
Param1=$1
Param2=$2
Param3=$3
# REGISTER Table # REGISTER Table
REG_pca9641_controll="0x01" REG_pca9641_controll="0x01"
REG_adc128_config="0x00" REG_adc128_config="0x00"
@ -175,6 +180,14 @@ print_usage(){
echo " : ./nicsensor.sh pcie0 fru 0x57 read" echo " : ./nicsensor.sh pcie0 fru 0x57 read"
echo " : ./nicsensor.sh pcie0 fru 0x57 write /tmp/fru.bin" echo " : ./nicsensor.sh pcie0 fru 0x57 write /tmp/fru.bin"
echo "" echo ""
echo " Function 5 - Settings"
echo " 1) Command Format : ./nicsensor.sh [get/set] [property] [value]"
echo " 2) Option Detail"
echo " - [property] : debug, detect, server"
echo " - [value] : property's value"
echo " 3) E.G. : ./nicsensor.sh set server 5280m7"
echo " : ./nicsensor.sh set debug 1"
echo " : ./nicsensor.sh set detect 1"
} }
# print format message to console|debuglog # print format message to console|debuglog
@ -242,6 +255,50 @@ parse_nic_slot(){
fmt_print "log" $INFO "Slot Num : $slot_number" fmt_print "log" $INFO "Slot Num : $slot_number"
} }
get_set_properties(){
if [ "$Param2" = "server" ];then
target_file="/tmp/ns_servertype"
default_data=$server_type
elif [ "$Param2" = "debug" ];then
target_file="/tmp/ns_debugmode"
default_data=$DEBUG_MODE
elif [ "$Param2" = "detect" ];then
target_file="/tmp/ns_disabledetect"
default_data=$DISABLE_DETECT
else
fmt_print "console" $ERROR "Invalid Property : $Param2"
exit 1
fi
if [ "$Param1" = "get" ];then
if [ -e "$target_file" ];then
tmpdata=`cat $target_file`
fmt_print "console" $INFO "$Param2 : $tmpdata"
else
fmt_print "console" $INFO "$Param2 : $default_data"
fi
else
echo $Param3 > $target_file
fmt_print "console" $INFO "Set $Param3 -> $Param2 successfully"
fi
exit 0
}
load_properties_from_cache(){
if [ -e "/tmp/ns_servertype" ];then
server_type=`cat /tmp/ns_servertype`
fi
if [ -e "/tmp/ns_debugmode" ];then
DEBUG_MODE=`cat /tmp/ns_debugmode`
fi
if [ -e "/tmp/ns_disabledetect" ];then
DISABLE_DETECT=`cat /tm/ns_disabledetect`
fi
}
# According to boardid, parse server_type # According to boardid, parse server_type
try_get_server_type(){ try_get_server_type(){
if [ -e "/tmp/ns_servertype" ];then if [ -e "/tmp/ns_servertype" ];then
@ -283,10 +340,14 @@ init_debuglog(){
fmt_print "log" $INFO "Debug Mode : $DEBUG_MODE" fmt_print "log" $INFO "Debug Mode : $DEBUG_MODE"
fmt_print "log" $INFO "Disable Detect : $DISABLE_DETECT" fmt_print "log" $INFO "Disable Detect : $DISABLE_DETECT"
if [ "$nic_slot" = "detect" ];then if [ "$Param1" = "detect" ];then
fmt_print "log" $INFO "Operation Type : i2c detect" fmt_print "log" $INFO "Operation Type : i2c detect"
elif [ "$nic_slot" = "version" ];then elif [ "$Param1" = "version" ];then
fmt_print "log" $INFO "Operation Type : get version" fmt_print "log" $INFO "Operation Type : get version"
elif [ "$Param1" = "get" ];then
fmt_print "log" $INFO "Operation Type : get property value"
elif [ "$Param1" = "set" ];then
fmt_print "log" $INFO "Operation Type : set property value"
elif [ $param_num -lt 2 ];then elif [ $param_num -lt 2 ];then
fmt_print "log" $INFO "Operation Type : help info" fmt_print "log" $INFO "Operation Type : help info"
else else
@ -346,6 +407,11 @@ switch_pca9548_channel(){
pre_exec_hook(){ pre_exec_hook(){
init_debuglog init_debuglog
if [ "$Param1" = "get" ] || [ "$Param1" = "set" ];then
get_set_properties
fi
load_properties_from_cache
# check server_type if is auto # check server_type if is auto
# if in debug mode, skip this check # if in debug mode, skip this check
if [ "$server_type" = "auto" ] && [ $DEBUG_MODE -eq 0 ];then if [ "$server_type" = "auto" ] && [ $DEBUG_MODE -eq 0 ];then
@ -353,7 +419,7 @@ pre_exec_hook(){
fi fi
# is param legel? # is param legel?
if [ "$sensor_type" = "chip" ];then if [ "$Param2" = "chip" ];then
if [ $param_num -le 3 ];then if [ $param_num -le 3 ];then
fmt_print "console" $ERROR "Command Format illegal" fmt_print "console" $ERROR "Command Format illegal"
echo "Command Format : ./nicsensor.sh [slot] chip [slave] [i2c_command]" echo "Command Format : ./nicsensor.sh [slot] chip [slave] [i2c_command]"
@ -362,7 +428,7 @@ pre_exec_hook(){
fi fi
# if the action is fru write, need pre-process fru data # if the action is fru write, need pre-process fru data
if [ "$sensor_type" = "fru" ];then if [ "$Param2" = "fru" ];then
if [ "$option_data" = "write" ];then if [ "$option_data" = "write" ];then
fmt_print "log" $INFO "Opreation FRU Write" fmt_print "log" $INFO "Opreation FRU Write"

@ -7,22 +7,23 @@
- [nicsensor工具使用说明](#nicsensor工具使用说明) - [nicsensor工具使用说明](#nicsensor工具使用说明)
- [目录](#目录) - [目录](#目录)
- [1 简介](#1_简介) - [1\_简介](#1_简介)
- [2 使用方法](#2_使用方法) - [2\_使用方法](#2_使用方法)
- [2.1 传感器读取](#2_1_传感器读取) - [2\_1\_传感器读取](#2_1_传感器读取)
- [2.2 FRU相关操作](#2_2_fru相关操作) - [2\_2\_FRU相关操作](#2_2_fru相关操作)
- [2.3 命令透传](#2_3_命令透传) - [2\_3\_命令透传](#2_3_命令透传)
- [2.4 插槽I2C信息遍历](#2_4_插槽i2c信息遍历) - [2\_4\_插槽I2C信息遍历](#2_4_插槽i2c信息遍历)
- [2.5 调试模式使用](#2_5_调试模式使用) - [2\_5\_调试模式使用](#2_5_调试模式使用)
- [2.6 扩展功能](#2_6_扩展功能) - [2\_6\_扩展功能](#2_6_扩展功能)
- [3 常见问题](#3_常见问题) - [2\_7\_设定配置功能](#2_7_设定配置功能)
- [3.1 ADC128传感器读值为0](#3_1_adc128传感器读值为0) - [3\_常见问题](#3_常见问题)
- [3.2 脚本执行时出现大批量语法错误](#3_2_脚本执行时出现大批量语法错误) - [3\_1\_ADC128传感器读值为0](#3_1_adc128传感器读值为0)
- [4 附属工具](#4_附属工具) - [3\_2\_脚本执行时出现大批量语法错误](#3_2_脚本执行时出现大批量语法错误)
- [4.1 FruParse](#4_1_fruparse) - [4\_附属工具](#4_附属工具)
- [5 关于nicsensor_v2](#5_关于nicsensor_v2) - [4\_1\_FruParse](#4_1_fruparse)
- [6 附录](#6_附录) - [5\_关于nicsensor\_v2](#5_关于nicsensor_v2)
- [6.1 Project变量说明](#6_1_project变量说明) - [6\_附录](#6_附录)
- [6\_1\_Project变量说明](#6_1_project变量说明)
## 1_简介 ## 1_简介
@ -144,6 +145,30 @@ nicsensor工具是在带有i2ctool工具(i2ctransfer、i2cdetect)的BMC下用于
`handle_reserve` 中可以自定义需要对网卡实现的功能。在调用该函数之前脚本会将 PCA9641及PCA9548选通。扩展功能时无需考虑PCA9641和PCA9548的状态。 `handle_reserve` 中可以自定义需要对网卡实现的功能。在调用该函数之前脚本会将 PCA9641及PCA9548选通。扩展功能时无需考虑PCA9641和PCA9548的状态。
### 2_7_设定配置功能
> [!warning]
> 版本要求:
> - 测试版本 1.7.7 以上
> - 正式版本 1.8 及以上
可以通过一组名为 `get/set` 的指令对脚本中的如下变量做即时修改而无需修改脚本本体。支持修改的变量如下:
- `server_type` : 对应属性值缩写 `server`
- `DEBUG_MODE` : 对应属性值缩写 `debug`
- `DISABLE_DETECT` : 对应属性值缩写 `detect`
**命令格式**
``` shell
./nicsensor.sh <get/set> <property> <value>
```
**命令示例**
``` shell
./nicsensor.sh set server 5280m7
./nicsneosr.sh get debug
```
## 3_常见问题 ## 3_常见问题
### 3_1_ADC128传感器读值为0 ### 3_1_ADC128传感器读值为0