summaryrefslogtreecommitdiff
path: root/package/alix-temperature/files/alix-temperature
blob: cdcf5c1fe4eba6d691f52d91b4d88af8d967afe3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
# temperature.sh
# this tool reads the lm86 from pcengines alix mainboards.
# http://pcengines.ch/alix.htm
# tested only on alix2d13 but should work on the other
# alix2dxx and alix3dxx boards too.
#
# Copyright (C) 2011 Tobias Breckle <tobias.breckle@stz-bt.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

CMD="i2cget -y 0 0x4c"

TEMP_LOCAL=`$CMD 0x00`
TEMP_REMOTE_HIGH=`$CMD 0x01`
TEMP_REMOTE_LOW=`$CMD 0x10`

let "TEMP_REMOTE_LOW >>= 5"
let "TEMP_REMOTE_LOW = TEMP_REMOTE_LOW * 125"

if [ "$1" = "local" ]
then
        printf "Local:\t%d\n" $TEMP_LOCAL
elif [ "$1" = "remote" ]
then
        printf "Remote:\t%d,%d\n" $TEMP_REMOTE_HIGH $TEMP_REMOTE_LOW
elif [ -z "$1" ]
then
        printf "Local:\t%d\n" $TEMP_LOCAL
        printf "Remote:\t%d,%d\n" $TEMP_REMOTE_HIGH $TEMP_REMOTE_LOW
fi