Onewire/Example/Shell (Deutsch)

From Ethersex_Wiki
Revision as of 00:13, 16 April 2012 by Mgue (talk | contribs) (taken from Onewire)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Einfaches SH (Linux Shell) Script von stesie (irc) zum Auslesen von einem Wert (udp support muss enabled sein oder option -u nicht verwenden!)

#! /bin/sh
SENSORID=10529f7001080016
#ESEXIP=2001:6f8:1209:23:42::17 #IPv6 Adresse
ESEXIP=192.168.255.90
   
#IPv6
#echo 1w convert $SENSORID | nc6 -u $ESEXIP 2701 -q 1 2>/dev/null | grep -qe OK || exit 1 
#echo 1w get $SENSORID | nc6 -u $ESEXIP 2701 -q 1 2>/dev/null | sed -e 's/Temperatur: //' 
   
#IPv4
echo 1w convert $SENSORID | nc -u $ESEXIP 2701 -q 1 2>/dev/null | grep -qe OK || exit 1
echo 1w get $SENSORID | nc -u $ESEXIP 2701 -q 1 2>/dev/null | sed -e 's/Temperatur: //'

bash Script von Tron12 zum Auslesen aller Werte (Achtung Port 2701 ist nicht standard!! Sowie udp support muss enabled sein oder option -u nicht verwenden!)

#! /bin/sh
#
# netcat-openbsd  1.89-3ubuntu2

NETIOIP="-4 192.168.178.249"

#für IPv6:
#NETIOIP="-6 2001:6f8:1209:23:42::17"

NETIOPORT="2702"

N_DATE=`echo date | nc -u $NETIOIP $NETIOPORT -q 1 ` 
N_GET_ID=`echo 1w list | nc -u $NETIOIP $NETIOPORT -q 1 | grep -qe OK || exit 1`

echo "Date:     $N_DATE"
echo "---------------------------------"

for i in $N_GET_ID
do
	tmp=`echo 1w convert $i | nc -u $NETIOIP $NETIOPORT -q 1 2>/dev/null | grep -qe OK || exit 1`
	tmp=`echo 1w get $i | nc -u $NETIOIP $NETIOPORT -q 1 2>/dev/null `
	echo "Sensor:  $i :: $tmp"
done