refactor(master : nicsensor) update to 1.5.6

1.update print_usage fuction
2.add feature : nicsensor.sh version
This commit is contained in:
leimingsheng 2025-04-22 14:24:38 +08:00
parent a3f5e1a151
commit 2a2ee7fc99

@ -138,7 +138,7 @@ ina3221_ch2_volt="0"
ina3221_ch0_current="0"
ina3221_ch1_current="0"
ina3221_ch2_current="0"
SCRIPT_VERSION="1.5 Rev5 Intest"
SCRIPT_VERSION="1.5 Rev6 Intest"
fru_file_name=$option_data2
fru_write_size=0
@ -150,50 +150,41 @@ res_tmp468=""
# ---------------------------------------------------------
# Script Function Defination
# ---------------------------------------------------------
print_ocp_usage(){
echo "----------------------------------------------------------------"
echo " To test OCP Nic on server, support command as:"
echo " 1.detect function"
echo " ./nicsensor.sh detect ocp"
echo " 2.Reading sensors"
echo " ./nicsensor.sh ocp0 emc1413 0x4c"
echo ""
echo " Now only 5280m7 support to test ocp card"
echo ""
}
# script usage
print_usage(){
echo ""
echo "================>>> nicsensor script usage <<<=================="
echo " Command Format : ./nicsensor.sh [slot] [sensor tpye] [slave]"
echo " Option Detail"
echo " [slot] : 0 1 2 3 4 5 ..."
echo " [sensor type] : $Support_Sensor_List"
echo " [slave] : chip slave address , please provide 7 bit address"
echo " E.G. : ./nicsensor.sh 1 adc128 0x1f"
echo " ./nicsensor.sh pcie1 ina3221 0x42"
echo " ./nicsensor.sh ocp0 emc1413 0x4c"
echo " Function 1 - Read Sensor Value"
echo " 1) Command Format : ./nicsensor.sh [slot] [sensor tpye] [slave]"
echo " 2) Option Detail"
echo " - [slot] : 0 1 2 3 4 5 ..."
echo " - [sensor type] : $Support_Sensor_List"
echo " - [slave] : chip slave address , please provide 7 bit address"
echo " 3) E.G. : ./nicsensor.sh 1 adc128 0x1f"
echo " ./nicsensor.sh pcie1 ina3221 0x42"
echo " ./nicsensor.sh ocp0 emc1413 0x4c"
echo ""
if [ $DEBUG_MODE -eq 1 ];then
echo " Server Type : Debug Mode"
else
echo " Server Type : $server_type"
fi
echo " Function 2 - Detect I2C for each slot"
echo " 1) Command Format : ./nicsensor.sh detect [pcie/ocp]"
echo " 2) E.G. : ./nicsensor.sh detect pcie"
echo " ./nicsensor.sh detect ocp [some server don't support]"
echo " 3) Note : This function now only support on server:"
echo " $Support_Server_List"
echo ""
echo " To Auto detect i2c slave on server, please use:"
echo " ./nicsensor.sh detect"
echo " ./nicsensor.sh detect pcie"
echo " ./nicsensor.sh detect ocp [some server don't support]"
echo " This function now only support on server:"
echo " $Support_Server_List"
echo " Function 3 - Set i2c command to chip on Nic"
echo " 1) Command Format : ./nicsensor.sh [slot] chip [slave] [command]"
echo " 2) Option Detail"
echo " - [slot] : 0 1 2 3 4 5 ..."
echo " - [slave] : chip slave address , please provide 7 bit address"
echo " - [command] : The i2c command which will set to the chip"
echo ""
echo " If want to read/write chip register, use the below format"
echo " ./nicsensor.sh [slot] chip [slave] [i2c_command]"
echo " i2c_command : such as [i2ctransfer -y 13 w1@0x10 0x00 r2]"
echo " Function 4 - FRU Read and Wirte"
echo " 1) Command Format : ./nicsensor.sh [slot] fru [slave] [option] [frudata]"
echo " 2) Option Detail"
echo " - [slot] : 0 1 2 3 4 5 ..."
echo " - [slave] : chip slave address , please provide 7 bit address"
echo " - [option] : read/write, default to read"
echo " - [frudata] : fru bin file which will write to eeprom, only for write option"
echo ""
print_ocp_usage
}
print_chip_command_format(){
@ -1448,6 +1439,13 @@ start_detect_device(){
conf_pre_check
if [ "$1" == "version" ];then
echo "Script Version : $SCRIPT_VERSION"
echo "Debug Mode : $DEBUG_MODE"
echo "Disable Detect : $DISABLE_DETECT"
exit 0
fi
# is param legel?
if [ "$sensor_type" == "chip" ];then
if [ $# -le 3 ];then