Update rainsensorqty to version 0.2.5

This commit is contained in:
lejubila
2020-04-08 22:17:14 +02:00
parent 3a5c3ef934
commit 15e36e95a3
11 changed files with 331 additions and 58 deletions

View File

@@ -1,5 +1,6 @@
# 0.6.0 - xx/04/2020 # 0.6.0 - xx/04/2020
- Ass support for enable all cron fron api - Add support for enable all cron fron api
- Update rainsensorqty driver to version 0.2.5
# 0.5.14 - 24/09/2019 # 0.5.14 - 24/09/2019
- Updated rainsensorqty driver to version 0.2.3 - Updated rainsensorqty driver to version 0.2.3

View File

@@ -2,8 +2,8 @@
# Driver rainsensorqty - driver for measure the rain volume # Driver rainsensorqty - driver for measure the rain volume
# Author: androtto # Author: androtto
# file README.md # file README.md
# Version: 0.2.30 # Version: 0.2.5
# Data: 21/Sep/2019 # Data: 07/Apr/2020
FILE DI CONFIGURAZIONE /etc/piGarden.conf: FILE DI CONFIGURAZIONE /etc/piGarden.conf:
@@ -37,19 +37,38 @@ nella sottodirectory command sono presenti:
commands/rainsensorqty_CHECK.sh commands/rainsensorqty_CHECK.sh
chiama la funzione di verifica pioggia, la medesima chiamata da check_rain_sensor chiama la funzione di verifica pioggia, la medesima chiamata da check_rain_sensor
commands/rainsensorqty_HISTORY.sh commands/rainsensorqty_HISTORY.sh
visualizza lo storico della pioggia visualizza lo storico della pioggia consultando il file $RAINSENSORQTY_HISTORY
puo' essere lanciato con l''opzione -force per ricostruire il file $RAINSENSORQTY_HISTORY dal $RAINSENSORQTY_HISTORYRAW
e con un argomento X, che permette di evidenziare solo gli ultimi X eventi
commands/rainsensorqty_HISTORYRAW.sh
visualizza lo storico della pioggia consultando il file $RAINSENSORQTY_HISTORYRAW
puo' essere lanciato senza argomenti per processare l'intero file, chiede conferma visto che i tempi sono potenzialmente lunghi
con un argomento X, che permette di evidenziare solo gli ultimi X eventi
commands/rainsensorqty_INIT.sh commands/rainsensorqty_INIT.sh
inizializza il driver eseguendo lo script di monitoring - normalmente tale processo avviene da piGarden.sh inizializza il driver eseguendo lo script di monitoring - normalmente tale processo avviene da piGarden.sh
utile quando si vuole testare dei cambiamenti o se necessario riavviare dopo il kill del comando successivo utile quando si vuole testare dei cambiamenti o se necessario riavviare dopo il kill del comando successivo
commands/rainsensorqty_KILL.sh commands/rainsensorqty_KILL.sh
killa i processi di monitoring ed eventuali figli killa i processi di monitoring ed eventuali figli
commands/rainsensorqty_RAINNOW.sh commands/rainsensorqty_RAINNOW.sh
simula una pioggia registrandola in $RAINSENSORQTY_LASTRAIN simula una pioggia registrandola in $RAINSENSORQTY_LASTRAIN $RAINSENSORQTY_HISTORY $RAINSENSORQTY_HISTORYRAW
puo' essere lanciato in 3 modi:
senza argomenti: genera una pioggia per un numero di loop pari al valore della variabile RAINSENSORQTY_LOOPSFORSETRAINING, quindi una pioggia completa
con un argomento: che indica quanti loop
con due argomenti: quanti loop e quanti secondi tra uno e l'altro
commands/rainsensorqty_REMOVELASTRAIN.sh commands/rainsensorqty_REMOVELASTRAIN.sh
rimuove dai file $RAINSENSORQTY_LASTRAIN $RAINSENSORQTY_HISTORY l'ultima pioggia registrata rimuove dai file $RAINSENSORQTY_LASTRAIN $RAINSENSORQTY_HISTORY $RAINSENSORQTY_HISTORYRAW l'ultima pioggia registrata
commands/rainsensorqty_RESET.sh commands/rainsensorqty_RESET.sh
invia il SIGUSR1 al processo di monitor per resettare i cicli. Viene visualizzato il reset solo dopo il successivo PULSE, questo perche' non e' possibile per lo script ricevere il trap in quanto il processo $GPIO e' attivo in attesa del PULSE invia il SIGUSR1 al processo di monitor per resettare i cicli. Viene visualizzato il reset solo dopo il successivo PULSE, questo perche' non e' possibile per lo script ricevere il trap in quanto il processo $GPIO e' attivo in attesa del PULSE
questi i timestamps alla data del file:
-rwxr-xr-x 1 pi pi 1044 Sep 24 18:26 rainsensorqty_CHECK.sh
-rwxr-xr-x 1 pi pi 1139 Nov 28 00:17 rainsensorqty_HISTORYRAW.sh
-rwxr-xr-x 1 pi pi 1462 Nov 19 00:19 rainsensorqty_HISTORY.sh
-rwxr-xr-x 1 pi pi 596 Sep 24 18:26 rainsensorqty_INIT.sh
-rwxr-xr-x 1 pi pi 1300 Sep 24 18:26 rainsensorqty_KILL.sh
-rwxr-xr-x 1 pi pi 1111 Nov 27 00:05 rainsensorqty_RAINNOW.sh
-rwxr-xr-x 1 pi pi 1252 Nov 22 00:18 rainsensorqty_REMOVELASTRAIN.sh
-rwxr-xr-x 1 pi pi 897 Sep 24 18:26 rainsensorqty_RESET.sh
ULTERIORI VARIABILI in config.include.sh ULTERIORI VARIABILI in config.include.sh
---------------------------------------- ----------------------------------------
@@ -65,14 +84,14 @@ RAINSENSORQTY_LASTRAIN="$STATUS_DIR/rainsensorqty_lastrain"
memorizza l'ultima pioggia memorizza l'ultima pioggia
RAINSENSORQTY_HISTORY="$STATUS_DIR/rainsensorqty_history" RAINSENSORQTY_HISTORY="$STATUS_DIR/rainsensorqty_history"
memorizza tutte le piogge permettendo di visualizzare lo storico (commands/rainsensorqty_HISTORY.sh) memorizza tutte le piogge permettendo di visualizzare lo storico (commands/rainsensorqty_HISTORY.sh)
RAINSENSORQTY_HISTORYRAW="$STATUS_DIR/rainsensorqty_history.raw"
memorizza in formato grezzo (raw) tutti gli impulsi registrati (formato: "secondi:impulsi" ) - consultabile il contenuto con commands/rainsensorqty_HISTORYRAW.sh
RAINSENSORQTY_MONITORLOG="$DIR_SCRIPT/log/rainsensorqty_monitor.log" RAINSENSORQTY_MONITORLOG="$DIR_SCRIPT/log/rainsensorqty_monitor.log"
log dello script di monitoring, popolato solo se RAINSENSORQTY_verbose="yes" log dello script di monitoring, popolato solo se RAINSENSORQTY_verbose="yes"
RAINSENSORQTY_MONPID="$TMPDIR/rainsensorqty_monitor.pid" RAINSENSORQTY_MONPID="$TMPDIR/rainsensorqty_monitor.pid"
file che viene popolato con il pid dello script di monitoring file che viene popolato con il pid dello script di monitoring
RAINSENSORQTY_STATE="$TMPDIR/rainsensorqty_state"
file che viene popolato con l'ultimo stato della vaschetta (formato timestamp:counter)
RAINSENSORQTY_DIR="$DIR_SCRIPT/drv/rainsensorqty" RAINSENSORQTY_DIR="$DIR_SCRIPT/drv/rainsensorqty"
home directory del driver home directory del driver
@@ -103,5 +122,3 @@ GPIO_RESISTOR="none" #pull-up|pull-down|none
se lo stato di riposo e' 1, lo script attende la variazione verso 0 (falling) se lo stato di riposo e' 1, lo script attende la variazione verso 0 (falling)
la variabile RAINSENSORQTY_PULSE viene impostata secondo il valore di RAIN_GPIO_STATE presente in /etc/piGarden.conf la variabile RAINSENSORQTY_PULSE viene impostata secondo il valore di RAIN_GPIO_STATE presente in /etc/piGarden.conf
cioe' il valore che ci si aspetta per registrare il riempimento della vaschetta dello stato di pioggia cioe' il valore che ci si aspetta per registrare il riempimento della vaschetta dello stato di pioggia

View File

@@ -4,8 +4,8 @@
# Author: androtto # Author: androtto
# file "rainsensorqty_CHECK.sh" # file "rainsensorqty_CHECK.sh"
# test script for checking rain status using drv_rainsensorqty_rain_sensor_get function # test script for checking rain status using drv_rainsensorqty_rain_sensor_get function
# Version: 0.2.0a # Version: 0.2.5
# Data: 13/Aug/2019 # Data: 08/Jan/2020
SCRIPTDIR="$(cd `dirname $0` ; pwd )" SCRIPTDIR="$(cd `dirname $0` ; pwd )"
SCRIPTNAME=${0##*/} SCRIPTNAME=${0##*/}
@@ -22,7 +22,38 @@ LOG_OUTPUT_DRV_FILE="$DIR_SCRIPT/log/$LOG_OUTPUT_DRV_FILE"
. ./init.include.sh . ./init.include.sh
. ./rainsensor.include.sh . ./rainsensor.include.sh
rain_history # update rain history file if not if [[ $1 = "-force" ]] ; then
if [[ -s $RAINSENSORQTY_HISTORY ]] ; then
echo backup $RAINSENSORQTY_HISTORY to ${RAINSENSORQTY_HISTORY}.old$$
cp $RAINSENSORQTY_HISTORY ${RAINSENSORQTY_HISTORY}.old$$
fi
echo "RAIN HISTORY" echo "generate all rain events to $RAINSENSORQTY_HISTORY"
cat $RAINSENSORQTY_HISTORY | rain_when_amount if ! rainevents > ${RAINSENSORQTY_HISTORY} ; then
echo "WARNING: rainevents function had error"
fi
shift
fi
if ! rain_history tmp ; then # update rain history with last rain if not
echo "WARNING: rain_history function had error"
fi
cmd="cat"
if [[ $# > 0 ]] ; then
if (( $1 >= 1 )) ; then
echo "processing last $1 lines of $RAINSENSORQTY_HISTORYRAW file"
cmd="tail -$1"
else
echo "argument not recognized - exit"
exit 1
fi
fi
echo -e "\n\n"
if [[ -s $RAINSENSORQTY_HISTORY ]] ; then
echo "RAIN HISTORY"
cat $RAINSENSORQTY_HISTORY $RAINSENSORQTY_HISTORYTMP | $cmd | rain_when_amount
else
echo "WARNING: no \$RAINSENSORQTY_HISTORY file"
fi

View File

@@ -0,0 +1,50 @@
#!/bin/bash
#
# Driver rainsensorqty - driver for measure the rain volume
# Author: androtto
# file "rainsensorqty_CHECK.sh"
# test script for checking rain status using drv_rainsensorqty_rain_sensor_get function
# Version: 0.2.5
# Data: 07/Apr/2020
SCRIPTDIR="$(cd `dirname $0` ; pwd )"
SCRIPTNAME=${0##*/}
cd $SCRIPTDIR/.. # command is a subdirectory of driver
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
CONFIG_ETC="/etc/piGarden.conf"
LOG_OUTPUT_DRV_FILE="$DIR_SCRIPT/log/$LOG_OUTPUT_DRV_FILE"
. $CONFIG_ETC
. ./common.include.sh
. ./config.include.sh
. ./init.include.sh
. ./rainsensor.include.sh
if [[ $# = 0 ]] ; then
cmd=cat
echo "processing all entire $RAINSENSORQTY_HISTORYRAW file, will go on? (y/n)"
read answer
echo $answer
[[ $answer = [yY] ]] || exit 1
else
if (( $1 >= 1 )) ; then
echo "processing $1 lines of $RAINSENSORQTY_HISTORYRAW file"
cmd="tail -$1"
else
echo "argument not recognized - exit"
exit 1
fi
fi
echo -e "\n\n"
$cmd $RAINSENSORQTY_HISTORYRAW | while read line
do
set -- ${line//:/ }
secs=$1
counter=$2
echo "$(sec2date $1):$counter"
done

View File

@@ -3,8 +3,8 @@
# Author: androtto # Author: androtto
# file "rainsensorqty_RAINNOW.sh" # file "rainsensorqty_RAINNOW.sh"
# test script for simulate rain ... now! # test script for simulate rain ... now!
# Version: 0.2.0a # Version: 0.2.5
# Data: 13/Aug/2019 # Data: 07/Apr/2020
SCRIPTDIR="$(cd `dirname $0` ; pwd )" SCRIPTDIR="$(cd `dirname $0` ; pwd )"
SCRIPTNAME=${0##*/} SCRIPTNAME=${0##*/}
@@ -19,8 +19,49 @@ CONFIG_ETC="/etc/piGarden.conf"
. ./init.include.sh . ./init.include.sh
. ./rainsensor.include.sh . ./rainsensor.include.sh
echo "RAIN now!" wait=0
echo "$(date +%s):$RAINSENSORQTY_LOOPSFORSETRAINING" > ${RAINSENSORQTY_LASTRAIN} timestart=$( date +%s)
if [[ $# -ne 0 ]] ; then
if [[ $# = 1 ]] ; then
howmany=$1
echo "one argument passed: rain event for $howmany loops"
(( time = timestart - howmany ))
elif [[ $# = 2 ]] ; then
howmany=$1
wait=$2
echo "two arguments passed: rain event for $howmany loops every $wait seconds"
(( time = timestart ))
else
echo "too many arguments... exit"
exit 1
fi
else
howmany=$RAINSENSORQTY_LOOPSFORSETRAINING
(( time = timestart - $RAINSENSORQTY_LOOPSFORSETRAINING ))
fi
echo "RAIN now! (for $howmany loops)"
for (( c=1; c<=$howmany; c++ ))
do
if (( wait > 0 )) ; then
time=$( date +%s)
else
(( time+= 1 ))
fi
linetoadd="$time:$c"
echo $linetoadd >> $RAINSENSORQTY_HISTORYRAW
sleep $wait
echo -e ".\c"
done
echo
if ! rain_history ; then # update rain history with last rain if not
echo "WARNING: rain_history function had error"
fi
echo $linetoadd > ${RAINSENSORQTY_LASTRAIN}
echo "file ${RAINSENSORQTY_LASTRAIN} updated." echo "file ${RAINSENSORQTY_LASTRAIN} updated."
echo -e "\nLAST RAIN:"
cat $RAINSENSORQTY_LASTRAIN | rain_when_amount echo "last 2 rain events:"
tail -2 $RAINSENSORQTY_HISTORY | rain_when_amount

View File

@@ -3,8 +3,8 @@
# Author: androtto # Author: androtto
# file "test_rainsensorqty_CHECK.sh" # file "test_rainsensorqty_CHECK.sh"
# test script for checking rain status using drv_rainsensorqty_rain_sensor_get function # test script for checking rain status using drv_rainsensorqty_rain_sensor_get function
# Version: 0.2.0a # Version: 0.2.5
# Data: 13/Aug/2019 # Data: 07/Apr/2020
SCRIPTDIR="$(cd `dirname $0` ; pwd )" SCRIPTDIR="$(cd `dirname $0` ; pwd )"
SCRIPTNAME=${0##*/} SCRIPTNAME=${0##*/}
@@ -26,26 +26,19 @@ LOG_OUTPUT_DRV_FILE="$DIR_SCRIPT/log/$LOG_OUTPUT_DRV_FILE"
# RAINSENSORQTY_LASTRAIN # RAINSENSORQTY_LASTRAIN
# RAINSENSORQTY_HISTORY # RAINSENSORQTY_HISTORY
rain_history # update rain history file if not echo "RAIN HISTORY - last two events"
tail -2 $RAINSENSORQTY_HISTORY
echo "RAIN HISTORY - last five events" tail -2 $RAINSENSORQTY_HISTORY | rain_when_amount
tail -5 $RAINSENSORQTY_HISTORY | rain_when_amount
echo -e "\nLAST RAIN"
cat $RAINSENSORQTY_LASTRAIN | rain_when_amount
#exit # for test
echo -e "\nbackup to .old files"
cp -p $RAINSENSORQTY_HISTORY ${RAINSENSORQTY_HISTORY}.old
cp -p $RAINSENSORQTY_LASTRAIN ${RAINSENSORQTY_LASTRAIN}.old
echo "...removing last event" echo "...removing last event"
head -n-1 ${RAINSENSORQTY_HISTORY}.old > $RAINSENSORQTY_HISTORY removelastrain
tail -1 $RAINSENSORQTY_HISTORY > $RAINSENSORQTY_LASTRAIN echo "...rebuilding ${RAINSENSORQTY_HISTORY} from ${RAINSENSORQTY_HISTORYRAW}"
if ! rainevents > ${RAINSENSORQTY_HISTORY} ; then
echo "WARNING: rainevents function had error"
fi
tail -1 ${RAINSENSORQTY_HISTORYRAW} > ${RAINSENSORQTY_LASTRAIN}
echo -e "\nnew RAIN HISTORY - last five events" echo -e "\nnew RAIN HISTORY - last two events"
tail -5 $RAINSENSORQTY_HISTORY | rain_when_amount tail -2 $RAINSENSORQTY_HISTORY
tail -2 $RAINSENSORQTY_HISTORY | rain_when_amount
echo -e "\nnew LAST RAIN"
cat $RAINSENSORQTY_LASTRAIN | rain_when_amount

View File

@@ -3,14 +3,19 @@
# Author: androtto # Author: androtto
# file "common.include.sh" # file "common.include.sh"
# common functions used by driver # common functions used by driver
# Version: 0.2.0a # Version: 0.2.5
# Data: 13/Aug/2019 # Data: 08/Jan/2020
#note: #note:
#RAINSENSORQTY_MONPID="$TMPDIR/rainsensorqty_monitor.pid" #RAINSENSORQTY_MONPID="$TMPDIR/rainsensorqty_monitor.pid"
# #
sec2date()
{
date --date="@$1"
}
d() # short date & time d() # short date & time
{ {
date '+%X-%x' date '+%X-%x'
@@ -57,13 +62,28 @@ en_echo() # enhanched echo - check verbose variable
rain_history() rain_history()
{ {
[[ ! -f $RAINSENSORQTY_HISTORYRAW ]] && return 1
[[ ! -f $RAINSENSORQTY_HISTORY ]] && touch $RAINSENSORQTY_HISTORY [[ ! -f $RAINSENSORQTY_HISTORY ]] && touch $RAINSENSORQTY_HISTORY
[[ ! -f $RAINSENSORQTY_LASTRAIN ]] && return 1 > $RAINSENSORQTY_HISTORYTMP
if grep -q ^$(<$RAINSENSORQTY_LASTRAIN)$ $RAINSENSORQTY_HISTORY ; then
: # do nothing if lastrainevent=$( rainevents 1 ) ; then
return 2 : # done ok
else else
cat $RAINSENSORQTY_LASTRAIN >> $RAINSENSORQTY_HISTORY echo "WARNING: rainevents function had errors"
return 1
fi
#old #if grep -q ^$(<$RAINSENSORQTY_LASTRAIN)$ $RAINSENSORQTY_HISTORY ; then
if grep -q ^${lastrainevent}$ $RAINSENSORQTY_HISTORY ; then
: # already present
return 0
else
: # missing and fixed
if [[ $1 == tmp ]] ; then
echo $lastrainevent > $RAINSENSORQTY_HISTORYTMP
else
echo $lastrainevent >> $RAINSENSORQTY_HISTORY
fi
return 0 return 0
fi fi
} }
@@ -71,12 +91,14 @@ rain_history()
rain_when_amount() rain_when_amount()
{ {
# from standard input # from standard input
# format $time:$endtime:$endsequence
cat - | while read line cat - | while read line
do do
set -- ${line//:/ } set -- ${line//:/ }
when=$1 start=$1
howmuch=$2 stop=$2
printf "RAINED on %s for %.2f mm\n" "$(date --date="@$1")" $( $JQ -n "$howmuch * $RAINSENSORQTY_MMEACH" ) howmuch=$3
printf "RAINED for %7.2f mm between %s and %s\n" $( $JQ -n "$howmuch * $RAINSENSORQTY_MMEACH" ) "$(date --date="@$start")" "$(date --date="@$stop")"
done done
} }
@@ -88,3 +110,54 @@ check_TMPDIR()
fi fi
} }
rainevents()
{
if [[ ! -f $RAINSENSORQTY_HISTORYRAW ]] ; then
#echo "WARNING: no \$RAINSENSORQTY_HISTORYRAW file"# cannot echo, redirected output
return 1
fi
case $1 in
[0-9]|[0-9][0-9]) howmanyevent=$1 ;;
# -1) skiplast=true ;;
*) howmanyevent=-1 ;;
esac
newloop=yes
tac $RAINSENSORQTY_HISTORYRAW | while read line
do
set -- ${line//:/ }
time=$1
sequence=$2
if [[ $newloop == yes ]] ; then
endtime=$time
endsequence=$sequence
newloop=no
fi
if (( sequence == 1 )) ; then
# [[ $skiplast=true ]] && { skilast=false ; continue ; }
echo $time:$endtime:$endsequence
newloop=yes
(( event +=1 ))
fi
(( howmanyevent == event )) && break
done | sort -k1n
}
removelastrain()
{
if [[ ! -f $RAINSENSORQTY_HISTORYRAW ]] ; then
echo "WARNING: no \$RAINSENSORQTY_HISTORYRAW file"
return 1
fi
next=false
tac $RAINSENSORQTY_HISTORYRAW | while read line
do
set -- ${line//:/ }
time=$1
sequence=$2
[[ $next = true ]] && echo $line
(( sequence == 1 )) && next=true
done | tac > ${RAINSENSORQTY_HISTORYRAW}_$$
mv ${RAINSENSORQTY_HISTORYRAW}_$$ $RAINSENSORQTY_HISTORYRAW
}

View File

@@ -0,0 +1,66 @@
#
# Driver rainsensorqty - driver for measure the rain volume
# Author: androtto
# file "config.include.sh"
# specific driver config file
# Version: 0.2.5
# Data: 08/Jan/2020
export TMPDIR=/tmp
RAINSENSOR_DEBOUNCE=0.3 # 0.3 seconds for manage debounce of reed contact
RAINSENSORQTY_verbose="yes" # yes/no
RAINSENSORQTY_LASTRAIN="$STATUS_DIR/rainsensorqty_lastrain"
RAINSENSORQTY_HISTORY="$STATUS_DIR/rainsensorqty_history"
RAINSENSORQTY_HISTORYRAW="$STATUS_DIR/rainsensorqty_history.raw"
RAINSENSORQTY_HISTORYTMP="$TMPDIR/rainsensorqty_history.tmp"
RAINSENSORQTY_MONITORLOG="$DIR_SCRIPT/log/rainsensorqty_monitor.log"
RAINSENSORQTY_MONPID="$TMPDIR/rainsensorqty_monitor.pid"
RAINSENSORQTY_STATE="$TMPDIR/rainsensorqty_state"
RAINSENSORQTY_STATE_HIST="$TMPDIR/rainsensorqty_state.history"
RAINSENSORQTY_DIR="$DIR_SCRIPT/drv/rainsensorqty"
monitor_sh="$RAINSENSORQTY_DIR/drv_rainsensorqty_monitor.sh"
# internal gpio resistor, 3 values: pull-up, pull-down, none
# pull-up/down if rain gauge is connected directly to raspberry
# none if connected through an optocoupler circuit
GPIO_RESISTOR="pull-up" #pull-up|pull-down|none
#rising means waiting for 1 status (from 0)
#falling means waiting for 0 status (from 1)
#RAINSENSORQTY_PULSE=rising # pull-down circuit (rest status is 0)
#RAINSENSORQTY_PULSE=falling # pull-up circuit (rest status is 1)
(( RAIN_GPIO_STATE == 1 )) && RAINSENSORQTY_PULSE=rising # pull-down circuit (rest status is 0)
(( RAIN_GPIO_STATE == 0 )) && RAINSENSORQTY_PULSE=falling # pull-up circuit (rest status is 1)
config_check()
{
var2check="RAINSENSOR_DEBOUNCE RAINSENSORQTY_verbose RAINSENSORQTY_LASTRAIN RAINSENSORQTY_HISTORY RAINSENSORQTY_MONITORLOG RAINSENSORQTY_MONPID RAINSENSORQTY_DIR monitor_sh"
for var in $var2check
do
#${!a}
if [[ -z ${!var} ]] ; then
echo "ERROR: \$$var not set"
exit 1
fi
done
if [[ -z $RAINSENSORQTY_PULSE ]] ; then
echo "ERROR: RAIN_GPIO_STATE not set in piGarden.conf"
exit 1
fi
return 0
case $GPIO_RESISTOR in
pull-up|pull-down|none) return 0 ;;
*) echo "ERROR: GPIO_RESISTOR not set correctly - values are \"pull-up|pull-down|none\" "
exit 1
;;
esac
}

View File

@@ -3,8 +3,8 @@
# Author: androtto # Author: androtto
# file "config.include.sh" # file "config.include.sh"
# specific driver config file # specific driver config file
# Version: 0.2.0 # Version: 0.2.5
# Data: 11/Aug/2019 # Data: 08/Jan/2020
export TMPDIR=/tmp export TMPDIR=/tmp
@@ -14,6 +14,8 @@ RAINSENSORQTY_verbose="yes" # yes/no
RAINSENSORQTY_LASTRAIN="$STATUS_DIR/rainsensorqty_lastrain" RAINSENSORQTY_LASTRAIN="$STATUS_DIR/rainsensorqty_lastrain"
RAINSENSORQTY_HISTORY="$STATUS_DIR/rainsensorqty_history" RAINSENSORQTY_HISTORY="$STATUS_DIR/rainsensorqty_history"
RAINSENSORQTY_HISTORYRAW="$STATUS_DIR/rainsensorqty_history.raw"
RAINSENSORQTY_HISTORYTMP="$TMPDIR/rainsensorqty_history.tmp"
RAINSENSORQTY_MONITORLOG="$DIR_SCRIPT/log/rainsensorqty_monitor.log" RAINSENSORQTY_MONITORLOG="$DIR_SCRIPT/log/rainsensorqty_monitor.log"

View File

@@ -4,8 +4,8 @@
# Author: androtto # Author: androtto
# file "drv_rainsensorqty_monitor.sh" # file "drv_rainsensorqty_monitor.sh"
# monitor script # monitor script
# Version: 0.2.2 # Version: 0.2.5
# Data: 08/Sep/2019 # Data: 08/Jan/2020
resetcounter() resetcounter()
{ {
@@ -76,8 +76,7 @@ do
fi fi
(( counter+=1 )) (( counter+=1 ))
en_echo "$RAINSENSORQTY_PULSE PULSE #$counter RECEIVED" en_echo "$RAINSENSORQTY_PULSE PULSE #$counter RECEIVED"
echo "$now:$counter" > ${RAINSENSORQTY_STATE} & echo "$now:$counter" >> ${RAINSENSORQTY_HISTORYRAW} &
echo "$now:$counter" >> ${RAINSENSORQTY_STATE_HIST} &
MMWATER=$( $JQ -n "$counter*$MMEACH" ) MMWATER=$( $JQ -n "$counter*$MMEACH" )
text=$(printf "%.2f mm height (#%d pulse)" $MMWATER $counter ) text=$(printf "%.2f mm height (#%d pulse)" $MMWATER $counter )
if (( counter >= RAINSENSORQTY_LOOPSFORSETRAINING )) ; then if (( counter >= RAINSENSORQTY_LOOPSFORSETRAINING )) ; then