#!/bin/sh

# script to print temperature sensor values for hg board

AP_PLATFORM=`cat /COOKIE_PID`
if [ ! -z "$AP_PLATFORM" ]; then
    case $AP_PLATFORM in
         *9117*)
                #Haida Gwaii
                f1="/sys/bus/i2c/devices/0-004c/hwmon/hwmon0/temp1_input"
                f2="/sys/bus/i2c/devices/0-004c/hwmon/hwmon0/temp2_input"
                f3="/sys/bus/i2c/devices/0-004c/hwmon/hwmon0/temp3_input"
                f4="/sys/bus/i2c/devices/0-004c/hwmon/hwmon0/temp4_input"
                #
                # Print temperatures
                #
                read t1 < $f1
                echo "On-chip sensor temp = $((t1/1000)) C"
                read t2 < $f2
                echo "Remote sensor 1 temp = $((t2/1000)) C"
                read t3 < $f3
                echo "Remote sensor 2 temp = $((t3/1000)) C"
                read t4 < $f4
                echo "Remote sensor 3 temp = $((t4/1000)) C"
                ;;
         *9130*)
                if [ -f /sys/bus/i2c/devices/0-004c/hwmon/hwmon0/temp4_input ]; then
                       #Axel with tmp423
                       f1="/sys/bus/i2c/devices/0-004c/hwmon/hwmon0/temp1_input"
                       f2="/sys/bus/i2c/devices/0-004c/hwmon/hwmon0/temp2_input"
                       f3="/sys/bus/i2c/devices/0-004c/hwmon/hwmon0/temp3_input"
                       f4="/sys/bus/i2c/devices/0-004c/hwmon/hwmon0/temp4_input"
                       #
                       # Print temperatures
                       #
                       read t1 < $f1
                       echo "On-chip sensor temp = $((t1/1000)) C"
                       read t2 < $f2
                       echo "Remote sensor 1 temp = $((t2/1000)) C"
                       read t3 < $f3
                       echo "Remote sensor 2 temp = $((t3/1000)) C"
                       read t4 < $f4
                       echo "Remote sensor 3 temp = $((t4/1000)) C"
                else
                       #Axel with lm75
                       f1="/sys/class/thermal/thermal_zone0/temp"
                       f2="/sys/bus/i2c/devices/0-0048/hwmon/hwmon0/temp1_input"
                       #
                       # Print temperatures
                       #
                       read t1 < $f1
                       echo "CPU temperature = $((t1/1)) C"
                       read t2 < $f2
                       echo "Remote sensor temperature = $((t2/1000)) C"
                fi
                ;;
         *)
            echo "Unknown AP type"
            ;;
        esac
fi


