Shell Skript: Temperatursensoren des AVR-NET-IO Boards abfragen
Mit dem folgenden Shell Skript können Sie die an einem AVR-NET-IO Board angeschlossenen DS18S20 Temperatursensoren (siehe AVR-NET-IO: Temperaturmessung mit den 1-Wire Sensoren DS18S20) abfragen.
###########################################################################
## ##
## Temperature Measurement with the AVR-NET-IO Board ##
## ##
## Creation: 14.07.2010 ##
## Last Update: 29.08.2010 ##
## ##
## Copyright (c) 2010 by Georg Kainzbauer <georgkainzbauer@gmx.net> ##
## ##
## 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 2 of the License, or ##
## (at your option) any later version. ##
## ##
###########################################################################
#!/bin/sh
# IP address of AVR-NET-IO board and port number
AVRNETIO_IP=192.168.10.50
AVRNETIO_PORT=2701
# Get IDs of 1-Wire sensors
SENSOR_ID=`echo 1w list | nc -w 2 $AVRNETIO_IP $AVRNETIO_PORT | grep -v OK || exit 1`
for i in $SENSOR_ID
do
# Initialize temperature measurement
`echo 1w convert $i | nc -w 2 $AVRNETIO_IP $AVRNETIO_PORT 2>/dev/null | grep -v OK || exit 1`
# Fetch measurement results
TEMP=`echo 1w get $i | nc -w 2 $AVRNETIO_IP $AVRNETIO_PORT 2>/dev/null`
# Print measurement results
echo "$i: $TEMP"
done
exit 0
## ##
## Temperature Measurement with the AVR-NET-IO Board ##
## ##
## Creation: 14.07.2010 ##
## Last Update: 29.08.2010 ##
## ##
## Copyright (c) 2010 by Georg Kainzbauer <georgkainzbauer@gmx.net> ##
## ##
## 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 2 of the License, or ##
## (at your option) any later version. ##
## ##
###########################################################################
#!/bin/sh
# IP address of AVR-NET-IO board and port number
AVRNETIO_IP=192.168.10.50
AVRNETIO_PORT=2701
# Get IDs of 1-Wire sensors
SENSOR_ID=`echo 1w list | nc -w 2 $AVRNETIO_IP $AVRNETIO_PORT | grep -v OK || exit 1`
for i in $SENSOR_ID
do
# Initialize temperature measurement
`echo 1w convert $i | nc -w 2 $AVRNETIO_IP $AVRNETIO_PORT 2>/dev/null | grep -v OK || exit 1`
# Fetch measurement results
TEMP=`echo 1w get $i | nc -w 2 $AVRNETIO_IP $AVRNETIO_PORT 2>/dev/null`
# Print measurement results
echo "$i: $TEMP"
done
exit 0
Hinweis: Da in diesem Skript für jeden einzelnen Sensor der Befehl 1w convert aufgerufen wird, wird bei einer größeren Anzahl von Sensoren die Ausführungsdauer unnötig vergrößert. Abhilfe schafft hier das folgende Skript.
###########################################################################
## ##
## Temperature Measurement with the AVR-NET-IO Board ##
## ##
## Creation: 14.07.2010 ##
## Last Update: 13.09.2010 ##
## ##
## Copyright (c) 2010 by Georg Kainzbauer <georgkainzbauer@gmx.net> ##
## ##
## 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 2 of the License, or ##
## (at your option) any later version. ##
## ##
###########################################################################
#!/bin/sh
# IP address of AVR-NET-IO board and port number
AVRNETIO_IP=192.168.10.50
AVRNETIO_PORT=2701
# Get IDs of 1-Wire sensors
SENSOR_ID=`echo 1w list | nc -w 2 $AVRNETIO_IP $AVRNETIO_PORT | grep -v OK || exit 1`
# Initialize temperature measurement
`echo 1w convert | nc -w 2 $AVRNETIO_IP $AVRNETIO_PORT 2>/dev/null | grep -v OK || exit 1`
for i in $SENSOR_ID
do
# Fetch measurement results
TEMP=`echo 1w get $i | nc -w 2 $AVRNETIO_IP $AVRNETIO_PORT 2>/dev/null`
# Print measurement results
echo "$i: $TEMP"
done
exit 0
## ##
## Temperature Measurement with the AVR-NET-IO Board ##
## ##
## Creation: 14.07.2010 ##
## Last Update: 13.09.2010 ##
## ##
## Copyright (c) 2010 by Georg Kainzbauer <georgkainzbauer@gmx.net> ##
## ##
## 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 2 of the License, or ##
## (at your option) any later version. ##
## ##
###########################################################################
#!/bin/sh
# IP address of AVR-NET-IO board and port number
AVRNETIO_IP=192.168.10.50
AVRNETIO_PORT=2701
# Get IDs of 1-Wire sensors
SENSOR_ID=`echo 1w list | nc -w 2 $AVRNETIO_IP $AVRNETIO_PORT | grep -v OK || exit 1`
# Initialize temperature measurement
`echo 1w convert | nc -w 2 $AVRNETIO_IP $AVRNETIO_PORT 2>/dev/null | grep -v OK || exit 1`
for i in $SENSOR_ID
do
# Fetch measurement results
TEMP=`echo 1w get $i | nc -w 2 $AVRNETIO_IP $AVRNETIO_PORT 2>/dev/null`
# Print measurement results
echo "$i: $TEMP"
done
exit 0
Dieser Eintrag wurde am 16.08.2010 erstellt und zuletzt am 13.09.2010 bearbeitet.
Direkter Link zu dieser Seite: http://www.gtkdb.de/index_7_1046.html
[ Zur Startseite ] [ Zur Kategorie ]
© 2004-2012 by Georg Kainzbauer
