#!/bin/bash function check_temp_cmosis (){ #sensor temp from bank reg local value=`pci -r 0x9110 -s 8 | grep 9110 | awk '{print $2}' | cut -c 1-8` local sensor_tmp=${value:4:4} sleep 0.01 local value=`pci -r 9030 | awk '{print $2}' | cut -c 6-6` # for 48 MHz use 48/40, for 40 MHz use 40/40 for clk_ratio offset can differ per # device if [ "$value" == "0" ]; then local clk_mhz=40 local clk_ratio=$(echo "scale = 2; 40/40" | bc) else local clk_mhz=48 local clk_ratio=$(echo "scale = 2; 48/40" | bc) fi local offset_zero_celsius=$(echo "scale = 2; 1000*$clk_ratio " | bc) local tmp_slope_sensor=$(echo "scale = 2; 0.3/$clk_ratio" | bc) # sensor temperature let "sensor_tmp=16#$sensor_tmp" # use 48/40 for 40MHz, or 40/40 for 40 MHz main clock sensor_tmp=$(echo "scale = 2; ($sensor_tmp-$offset_zero_celsius)*$tmp_slope_sensor" | bc) # echo "Sensor temperature,according to the datasheet: $sensor_tmp C" echo "Sensor temperature, clock $clk_mhz MHz: $sensor_tmp C" } function check_fpga_status () { #fpga temperature and monitor status from bank reg local value=`pci -r 0x9110 -s 8 | grep 9110 | awk '{print $2}' | cut -c 1-8` local fpga_tmp=${value:0:4} local fpga_mon=${value:0:1} # fpga monitor let "fpga_mon=16#$fpga_mon" fpga_mon=$(echo "ibase=10;obase=2;$fpga_mon" | bc) fpga_mon=$(printf "%04d\n" $fpga_mon) fpga_mon=${fpga_mon:0:3} # fpga temperature let "fpga_tmp=16#$fpga_tmp" fpga_tmp=$(echo "ibase=10;obase=2;$fpga_tmp" | bc) fpga_tmp=$(printf "%016d\n" $fpga_tmp) let "fpga_adc=2#${fpga_tmp:3:10}" fpga_tmp=$(echo "scale = 2; (($fpga_adc*503.975)/1024.)-273.15 " |bc) echo "FPGA temperature: $fpga_tmp C" if [ "$fpga_mon" != "000" ]; then echo "ERROR FPGA MONITOR: $fpga_mon" else echo "MONITOR OK" fi } input=$@ for i in "$@"; do case $i in --help) SHOW_USAGE=YES shift ;; --verbose) VERBOSE=YES shift ;; *) WRONG=YES shift ;; esac done if [ -z "$input" ]; then check_temp_cmosis check_fpga_status exit 0 fi if [ "$SHOW_USAGE" ]; then echo "Usage: status.sh [] [--help] [--verbose]" exit 0 fi if [ "$VERBOSE" ]; then check_temp_cmosis check_fpga_status pci -r 9000 -s 120 exit 0 fi if [ "$WRONG" ]; then echo -e "\e[31m !!!WRONG ARGUMENT!!!, check status.sh --help \033[1;m" exit fi