feat(script : nicsensor.sh) Update to version 1.2 Intest Rev5
1.支持INA3221传感器测试时的传感器名称定制化
This commit is contained in:
parent
6c98851598
commit
fba2e6f2f5
@ -1,6 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# script Version 1.1 20240912
|
|
||||||
# 支持测试的传感器芯片 emc1413 ina3221 adc128
|
# 支持测试的传感器芯片 emc1413 ina3221 adc128
|
||||||
# 支持通过 chip 参数直接做I2C命令透传来访问芯片寄存器
|
# 支持通过 chip 参数直接做I2C命令透传来访问芯片寄存器
|
||||||
# 支持通过 fru 参数读取FRU十六进制内容
|
# 支持通过 fru 参数读取FRU十六进制内容
|
||||||
@ -34,6 +33,11 @@ shunt_resistor_0="2"
|
|||||||
shunt_resistor_1="2"
|
shunt_resistor_1="2"
|
||||||
shunt_resistor_2="5"
|
shunt_resistor_2="5"
|
||||||
|
|
||||||
|
# INA3221 channel名称定制(可更换为对应的 电压/电流/温度 的名称)
|
||||||
|
INA3221_Channel0_name="Channel 0"
|
||||||
|
INA3221_Channel1_name="Channel 1"
|
||||||
|
INA3221_Channel2_name="Channel 2"
|
||||||
|
|
||||||
# EMC1413 channel名称定制(可更换为对应的 电压/电流/温度 的名称)
|
# EMC1413 channel名称定制(可更换为对应的 电压/电流/温度 的名称)
|
||||||
EMC1413_Channel0_name="Channel 0"
|
EMC1413_Channel0_name="Channel 0"
|
||||||
EMC1413_Channel1_name="Channel 1"
|
EMC1413_Channel1_name="Channel 1"
|
||||||
@ -134,7 +138,7 @@ 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.2 InTest Rev4"
|
SCRIPT_VERSION="1.2 InTest Rev5"
|
||||||
|
|
||||||
fru_file_name=$option_data2
|
fru_file_name=$option_data2
|
||||||
fru_write_size=0
|
fru_write_size=0
|
||||||
@ -591,6 +595,7 @@ process_adc128(){
|
|||||||
# @Param4 0代表数据是shunt volt
|
# @Param4 0代表数据是shunt volt
|
||||||
# 1代表数据是bus volt
|
# 1代表数据是bus volt
|
||||||
# @Param5 分流电阻 (仅在 Param4 是 shunt volt时有用)
|
# @Param5 分流电阻 (仅在 Param4 是 shunt volt时有用)
|
||||||
|
# @Param6 定制化名称
|
||||||
convert_ina3221_data(){
|
convert_ina3221_data(){
|
||||||
# 将读取到的两位数据拼接起来
|
# 将读取到的两位数据拼接起来
|
||||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||||
@ -625,7 +630,7 @@ convert_ina3221_data(){
|
|||||||
# 格式化输出数据
|
# 格式化输出数据
|
||||||
format_volt=$(echo "$volt" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
format_volt=$(echo "$volt" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||||
|
|
||||||
echo "channel $3 : $format_volt V, hex value: $upper_hex_value"
|
echo "$6 : $format_volt V, hex value: $upper_hex_value"
|
||||||
|
|
||||||
if [ $3 -eq 0 ];then
|
if [ $3 -eq 0 ];then
|
||||||
ina3221_ch0_volt=$format_volt
|
ina3221_ch0_volt=$format_volt
|
||||||
@ -644,7 +649,7 @@ convert_ina3221_data(){
|
|||||||
format_current=$(echo "$current" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
format_current=$(echo "$current" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||||
format_current_mv=$(echo "$current_mv" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
format_current_mv=$(echo "$current_mv" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||||
|
|
||||||
echo "channel $3 : $format_current A, shunt volt: $format_current_mv mV, shunt resistor: $5 mOhm, hex value: $upper_hex_value"
|
echo "$6 : $format_current A, shunt volt: $format_current_mv mV, shunt resistor: $5 mOhm, hex value: $upper_hex_value"
|
||||||
|
|
||||||
if [ $3 -eq 0 ];then
|
if [ $3 -eq 0 ];then
|
||||||
ina3221_ch0_current=$format_current
|
ina3221_ch0_current=$format_current
|
||||||
@ -667,9 +672,9 @@ convert_ina3221_data(){
|
|||||||
|
|
||||||
total_power=$(echo "scale=4; $power_ch0 + $power_ch1 + $power_ch2" | bc)
|
total_power=$(echo "scale=4; $power_ch0 + $power_ch1 + $power_ch2" | bc)
|
||||||
|
|
||||||
echo "channel 0 : $format_power_ch0 W"
|
echo "$INA3221_Channel0_name : $format_power_ch0 W"
|
||||||
echo "channel 1 : $format_power_ch1 W"
|
echo "$INA3221_Channel1_name : $format_power_ch1 W"
|
||||||
echo "channel 2 : $format_power_ch2 W"
|
echo "$INA3221_Channel2_name : $format_power_ch2 W"
|
||||||
echo "total power: $total_power W"
|
echo "total power: $total_power W"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -697,14 +702,14 @@ read_ina3221_channel_value(){
|
|||||||
|
|
||||||
# start parse raw data
|
# start parse raw data
|
||||||
echo ">>> The INA3221 shunt value is :"
|
echo ">>> The INA3221 shunt value is :"
|
||||||
convert_ina3221_data $res_ch0 0 $INA3221_SHUNT_VOLT $shunt_resistor_0
|
convert_ina3221_data $res_ch0 0 $INA3221_SHUNT_VOLT $shunt_resistor_0 $INA3221_Channel0_name
|
||||||
convert_ina3221_data $res_ch1 1 $INA3221_SHUNT_VOLT $shunt_resistor_1
|
convert_ina3221_data $res_ch1 1 $INA3221_SHUNT_VOLT $shunt_resistor_1 $INA3221_Channel1_name
|
||||||
convert_ina3221_data $res_ch2 2 $INA3221_SHUNT_VOLT $shunt_resistor_2
|
convert_ina3221_data $res_ch2 2 $INA3221_SHUNT_VOLT $shunt_resistor_2 $INA3221_Channel2_name
|
||||||
|
|
||||||
echo ">>> The INA3221 bus value is :"
|
echo ">>> The INA3221 bus value is :"
|
||||||
convert_ina3221_data $res_bus0 0 $INA3221_BUS_VOLT
|
convert_ina3221_data $res_bus0 0 $INA3221_BUS_VOLT null $INA3221_Channel0_name
|
||||||
convert_ina3221_data $res_bus1 1 $INA3221_BUS_VOLT
|
convert_ina3221_data $res_bus1 1 $INA3221_BUS_VOLT null $INA3221_Channel1_name
|
||||||
convert_ina3221_data $res_bus2 2 $INA3221_BUS_VOLT
|
convert_ina3221_data $res_bus2 2 $INA3221_BUS_VOLT null $INA3221_Channel2_name
|
||||||
|
|
||||||
echo ">>> The INA3221 bus power is :"
|
echo ">>> The INA3221 bus power is :"
|
||||||
convert_ina3221_data 0 0 0 $INA3221_POWER
|
convert_ina3221_data 0 0 0 $INA3221_POWER
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user