Compare commits
2 Commits
509803da51
...
369c31b639
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
369c31b639 | ||
|
|
13944d8f06 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1 @@
|
||||
/tool/frudata.txt
|
||||
/tool/fru_parse/frudata.txt
|
||||
34
tool/plugin/plugin_adc128.sh
Normal file
34
tool/plugin/plugin_adc128.sh
Normal file
@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
# process sensor data then print to console
|
||||
# @Param 1 adc128 data high 8bit
|
||||
# @Param 2 adc128 data low 8bit
|
||||
# @Param 3 customization channel name
|
||||
# @Param 4 division factor
|
||||
convert_adc128_data(){
|
||||
# remove data prefix '0x'
|
||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||
merge_value="${hex_value1}${hex_value2}"
|
||||
|
||||
# bc calculator recognized upper case only, change data to upper case
|
||||
upper_hex_value=$(echo "$merge_value" | awk '{
|
||||
for(i=1; i<=length($0); i++){
|
||||
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
|
||||
printf toupper(substr($0,i,1));
|
||||
else
|
||||
printf substr($0,i,1);
|
||||
}
|
||||
print ""
|
||||
}')
|
||||
|
||||
# calculate dec value then print it to console
|
||||
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
|
||||
volt=$(echo "scale=4; $dec_val / 16 / 4096 * 2.65 / $4" | bc)
|
||||
format_volt=$(echo "$volt" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
|
||||
echo "$3 : $format_volt v, hex value: $upper_hex_value"
|
||||
}
|
||||
|
||||
# E.G. convert_adc128_data 0x08 0x20 "3V3" "1"
|
||||
convert_adc128_data $1 $2 $3 $4
|
||||
45
tool/plugin/plugin_emc1413.sh
Normal file
45
tool/plugin/plugin_emc1413.sh
Normal file
@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
# @Param1 emc1413 data high 8bit
|
||||
# @Param2 emc1413 data low 8bit
|
||||
# @Param3 customization channel name
|
||||
convert_emc1413_data(){
|
||||
# remove data prefix '0x'
|
||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||
|
||||
# bc calculator recognized upper case only, change data to upper case
|
||||
upper_hex_value1=$(echo "$hex_value1" | awk '{
|
||||
for(i=1; i<=length($0); i++){
|
||||
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
|
||||
printf toupper(substr($0,i,1));
|
||||
else
|
||||
printf substr($0,i,1);
|
||||
}
|
||||
print ""
|
||||
}')
|
||||
upper_hex_value2=$(echo "$hex_value2" | awk '{
|
||||
for(i=1; i<=length($0); i++){
|
||||
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
|
||||
printf toupper(substr($0,i,1));
|
||||
else
|
||||
printf substr($0,i,1);
|
||||
}
|
||||
print ""
|
||||
}')
|
||||
|
||||
# change data from hex to dec
|
||||
dec_value1=$(echo "ibase=16; $upper_hex_value1" | bc)
|
||||
dec_value2=$(echo "ibase=16; $upper_hex_value2" | bc)
|
||||
|
||||
# calculate tempreture
|
||||
temp=$(echo "scale=4; $dec_value1 + ($dec_value2 / 32 * 0.125 )" | bc)
|
||||
|
||||
# print result to consol
|
||||
format_temp=$(echo "$temp" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
|
||||
echo "$3 : $format_temp C, hex value : $hex_value1 $hex_value2"
|
||||
|
||||
}
|
||||
|
||||
convert_emc1413_data $1 $2 $3
|
||||
79
tool/plugin/plugin_ina3221.sh
Normal file
79
tool/plugin/plugin_ina3221.sh
Normal file
@ -0,0 +1,79 @@
|
||||
#!/bin/sh
|
||||
|
||||
# @Param1 ina3221 data high 8bit
|
||||
# @Param2 ina3221 data high 8bit
|
||||
# @Param3 channel number
|
||||
# @Param4 mode select 0 - shunt volt
|
||||
# 1 - bus volt
|
||||
# @Param5 shunt resistor(only used in mode shunt volt)
|
||||
# @Param6 customization channel name
|
||||
convert_ina3221_data(){
|
||||
|
||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||
merge_value="${hex_value1}${hex_value2}"
|
||||
|
||||
# bc calculator recognized upper case only, change data to upper case
|
||||
upper_hex_value=$(echo "$merge_value" | awk '{
|
||||
for(i=1; i<=length($0); i++){
|
||||
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
|
||||
printf toupper(substr($0,i,1));
|
||||
else
|
||||
printf substr($0,i,1);
|
||||
}
|
||||
print ""
|
||||
}')
|
||||
|
||||
# change data from hex to dec
|
||||
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
|
||||
|
||||
if [ $4 -eq $INA3221_BUS_VOLT ];then
|
||||
volt=$(echo "scale=4; $dec_val / 8 * 40 / 10000 * 2" | bc)
|
||||
format_volt=$(echo "$volt" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
echo "$6 : $format_volt V, hex value: $upper_hex_value"
|
||||
|
||||
if [ $3 -eq 0 ];then
|
||||
ina3221_ch0_volt=$format_volt
|
||||
elif [ $3 -eq 1 ];then
|
||||
ina3221_ch1_volt=$format_volt
|
||||
else
|
||||
ina3221_ch2_volt=$format_volt
|
||||
fi
|
||||
|
||||
elif [ $4 -eq $INA3221_SHUNT_VOLT ];then
|
||||
current_mv=$(echo "scale=4; $dec_val / 8 * 40 / 1000" | bc)
|
||||
current=$(echo "scale=4; $current_mv / $5" | bc)
|
||||
|
||||
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 }')
|
||||
|
||||
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
|
||||
ina3221_ch0_current=$format_current
|
||||
elif [ $3 -eq 1 ];then
|
||||
ina3221_ch1_current=$format_current
|
||||
else
|
||||
ina3221_ch2_current=$format_current
|
||||
fi
|
||||
|
||||
elif [ $4 -eq $INA3221_POWER ];then
|
||||
# calculate power
|
||||
power_ch0=$(echo "scale=4; $ina3221_ch0_volt * $ina3221_ch0_current" | bc)
|
||||
power_ch1=$(echo "scale=4; $ina3221_ch1_volt * $ina3221_ch1_current" | bc)
|
||||
power_ch2=$(echo "scale=4; $ina3221_ch2_volt * $ina3221_ch2_current" | bc)
|
||||
|
||||
format_power_ch0=$(echo "$power_ch0" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
format_power_ch1=$(echo "$power_ch1" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
format_power_ch2=$(echo "$power_ch2" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
|
||||
total_power=$(echo "scale=4; $power_ch0 + $power_ch1 + $power_ch2" | bc)
|
||||
|
||||
echo "$INA3221_Channel0_name : $format_power_ch0 W"
|
||||
echo "$INA3221_Channel1_name : $format_power_ch1 W"
|
||||
echo "$INA3221_Channel2_name : $format_power_ch2 W"
|
||||
echo "total power: $total_power W"
|
||||
fi
|
||||
}
|
||||
|
||||
convert_ina3221_data $1 $2 $3 $4 $5 $6
|
||||
38
tool/plugin/plugin_tmp112.sh
Normal file
38
tool/plugin/plugin_tmp112.sh
Normal file
@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
# @Param1 tmp112 data high 8bit
|
||||
# @Param2 tmp112 data low 8bit
|
||||
# @Param3 customization sensor name
|
||||
convert_tmp112_data(){
|
||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||
merge_value="${hex_value1}${hex_value2}"
|
||||
|
||||
# bc calculator recognized upper case only, change data to upper case
|
||||
upper_hex_value=$(echo "$merge_value" | awk '{
|
||||
for(i=1; i<=length($0); i++){
|
||||
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
|
||||
printf toupper(substr($0,i,1));
|
||||
else
|
||||
printf substr($0,i,1);
|
||||
}
|
||||
print ""
|
||||
}')
|
||||
|
||||
# change data from hex to dec
|
||||
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
|
||||
|
||||
binary_number=$(echo "ibase=16;obase=2;$upper_hex_value" | bc)
|
||||
bin_length=$(echo $binary_number | awk '{print length($0)}')
|
||||
last_digit=$(echo $binary_number | cut -c $bin_length)
|
||||
if [ $last_digit -eq 0 ];then
|
||||
temp=$(echo "scale=4; $dec_val / 16 * 0.0625" | bc)
|
||||
elif [ $last_digit -eq 1 ];then
|
||||
temp=$(echo "scale=4; ( $dec_val - 1 ) / 8 * 0.0625" | bc)
|
||||
fi
|
||||
|
||||
echo "$3 : $temp"
|
||||
}
|
||||
|
||||
# E.G. ./plugin_tmp112.sh 0x08 0x40 temp
|
||||
convert_tmp112_data $1 $2 $3
|
||||
29
tool/plugin/plugin_tmp468.sh
Normal file
29
tool/plugin/plugin_tmp468.sh
Normal file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
# @Param1 tmp468 data high 8bit
|
||||
# @Param2 tmp468 data high 8bit
|
||||
# @Param3 customization channel name
|
||||
convert_tmp468_data(){
|
||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||
merge_value="${hex_value1}${hex_value2}"
|
||||
|
||||
# bc calculator recognized upper case only, change data to upper case
|
||||
upper_hex_value=$(echo "$merge_value" | awk '{
|
||||
for(i=1; i<=length($0); i++){
|
||||
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
|
||||
printf toupper(substr($0,i,1));
|
||||
else
|
||||
printf substr($0,i,1);
|
||||
}
|
||||
print ""
|
||||
}')
|
||||
|
||||
# change data from hex to dec
|
||||
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
|
||||
|
||||
temp=$(echo "scale=4; $dec_val / 8 * 0.0625" | bc)
|
||||
echo "$3 : $temp "
|
||||
}
|
||||
|
||||
convert_tmp468_data $1 $2 $3
|
||||
Loading…
Reference in New Issue
Block a user