versione 0.2.3
This commit is contained in:
@@ -69,9 +69,9 @@ RAINSENSORQTY_HISTORY="$STATUS_DIR/rainsensorqty_history"
|
|||||||
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="$TMP_PATH/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="$TMP_PATH/rainsensorqty_state"
|
RAINSENSORQTY_STATE="$TMPDIR/rainsensorqty_state"
|
||||||
file che viene popolato con l'ultimo stato della vaschetta (formato timestamp:counter)
|
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"
|
||||||
@@ -79,7 +79,9 @@ RAINSENSORQTY_DIR="$DIR_SCRIPT/drv/rainsensorqty"
|
|||||||
|
|
||||||
monitor_sh="$RAINSENSORQTY_DIR/drv_rainsensorqty_monitor.sh"
|
monitor_sh="$RAINSENSORQTY_DIR/drv_rainsensorqty_monitor.sh"
|
||||||
script di monitoring
|
script di monitoring
|
||||||
lo script eredita le variabili di ambiente da $RAINSENSORQTY_VAR ($TMP_PATH/.rainsensorqty_var)
|
lo script eredita le variabili di ambiente da $RAINSENSORQTY_VAR ($TMPDIR/.rainsensorqty_var)
|
||||||
|
|
||||||
|
NOTA: $TMPDIR e' /tmp e lo script visualizza un warning se non e' un tmpfs
|
||||||
|
|
||||||
# internal gpio resistor, 3 values: pull-up, pull-down, none
|
# internal gpio resistor, 3 values: pull-up, pull-down, none
|
||||||
# pull-up/down if rain gauge is connected directly to raspberry
|
# pull-up/down if rain gauge is connected directly to raspberry
|
||||||
|
|||||||
0
drv/rainsensorqty/_version_0.2.3
Normal file
0
drv/rainsensorqty/_version_0.2.3
Normal file
@@ -13,11 +13,6 @@ cd $SCRIPTDIR/.. # command is a subdirectory of driver
|
|||||||
|
|
||||||
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
|
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
|
||||||
CONFIG_ETC="/etc/piGarden.conf"
|
CONFIG_ETC="/etc/piGarden.conf"
|
||||||
TMP_PATH="/run/shm"
|
|
||||||
if [ ! -d "$TMP_PATH" ]; then
|
|
||||||
TMP_PATH="/tmp"
|
|
||||||
fi
|
|
||||||
|
|
||||||
LOG_OUTPUT_DRV_FILE="$DIR_SCRIPT/log/$LOG_OUTPUT_DRV_FILE"
|
LOG_OUTPUT_DRV_FILE="$DIR_SCRIPT/log/$LOG_OUTPUT_DRV_FILE"
|
||||||
|
|
||||||
. $CONFIG_ETC
|
. $CONFIG_ETC
|
||||||
|
|||||||
@@ -13,11 +13,6 @@ cd $SCRIPTDIR/.. # command is a subdirectory of driver
|
|||||||
|
|
||||||
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
|
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
|
||||||
CONFIG_ETC="/etc/piGarden.conf"
|
CONFIG_ETC="/etc/piGarden.conf"
|
||||||
TMP_PATH="/run/shm"
|
|
||||||
if [ ! -d "$TMP_PATH" ]; then
|
|
||||||
TMP_PATH="/tmp"
|
|
||||||
fi
|
|
||||||
|
|
||||||
LOG_OUTPUT_DRV_FILE="$DIR_SCRIPT/log/$LOG_OUTPUT_DRV_FILE"
|
LOG_OUTPUT_DRV_FILE="$DIR_SCRIPT/log/$LOG_OUTPUT_DRV_FILE"
|
||||||
|
|
||||||
. $CONFIG_ETC
|
. $CONFIG_ETC
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ cd $SCRIPTDIR/.. # command is a subdirectory of driver
|
|||||||
|
|
||||||
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
|
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
|
||||||
CONFIG_ETC="/etc/piGarden.conf"
|
CONFIG_ETC="/etc/piGarden.conf"
|
||||||
TMP_PATH="/run/shm"
|
|
||||||
if [ ! -d "$TMP_PATH" ]; then
|
|
||||||
TMP_PATH="/tmp"
|
|
||||||
fi
|
|
||||||
|
|
||||||
. $CONFIG_ETC
|
. $CONFIG_ETC
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ cd $SCRIPTDIR/.. # command is a subdirectory of driver
|
|||||||
|
|
||||||
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
|
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
|
||||||
CONFIG_ETC="/etc/piGarden.conf"
|
CONFIG_ETC="/etc/piGarden.conf"
|
||||||
TMP_PATH="/run/shm"
|
|
||||||
if [ ! -d "$TMP_PATH" ]; then
|
|
||||||
TMP_PATH="/tmp"
|
|
||||||
fi
|
|
||||||
|
|
||||||
. $CONFIG_ETC
|
. $CONFIG_ETC
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,6 @@ cd $SCRIPTDIR/.. # command is a subdirectory of driver
|
|||||||
|
|
||||||
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
|
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
|
||||||
CONFIG_ETC="/etc/piGarden.conf"
|
CONFIG_ETC="/etc/piGarden.conf"
|
||||||
TMP_PATH="/run/shm"
|
|
||||||
if [ ! -d "$TMP_PATH" ]; then
|
|
||||||
TMP_PATH="/tmp"
|
|
||||||
fi
|
|
||||||
|
|
||||||
. $CONFIG_ETC
|
. $CONFIG_ETC
|
||||||
|
|
||||||
. ./config.include.sh
|
. ./config.include.sh
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ cd $SCRIPTDIR/.. # command is a subdirectory of driver
|
|||||||
|
|
||||||
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
|
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
|
||||||
CONFIG_ETC="/etc/piGarden.conf"
|
CONFIG_ETC="/etc/piGarden.conf"
|
||||||
TMP_PATH="/run/shm"
|
|
||||||
if [ ! -d "$TMP_PATH" ]; then
|
|
||||||
TMP_PATH="/tmp"
|
|
||||||
fi
|
|
||||||
|
|
||||||
LOG_OUTPUT_DRV_FILE="$DIR_SCRIPT/log/$LOG_OUTPUT_DRV_FILE"
|
LOG_OUTPUT_DRV_FILE="$DIR_SCRIPT/log/$LOG_OUTPUT_DRV_FILE"
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ cd $SCRIPTDIR/.. # command is a subdirectory of driver
|
|||||||
|
|
||||||
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
|
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
|
||||||
CONFIG_ETC="/etc/piGarden.conf"
|
CONFIG_ETC="/etc/piGarden.conf"
|
||||||
TMP_PATH="/run/shm"
|
|
||||||
if [ ! -d "$TMP_PATH" ]; then
|
|
||||||
TMP_PATH="/tmp"
|
|
||||||
fi
|
|
||||||
|
|
||||||
. $CONFIG_ETC
|
. $CONFIG_ETC
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#note:
|
#note:
|
||||||
#RAINSENSORQTY_MONPID="$TMP_PATH/rainsensorqty_monitor.pid"
|
#RAINSENSORQTY_MONPID="$TMPDIR/rainsensorqty_monitor.pid"
|
||||||
#
|
#
|
||||||
|
|
||||||
d() # short date & time
|
d() # short date & time
|
||||||
@@ -80,3 +80,11 @@ do
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_TMPDIR()
|
||||||
|
{
|
||||||
|
if [[ $(df | awk '$NF=="/tmp" {print $1}') != "tmpfs" ]] ; then
|
||||||
|
echo "WARNING: /tmp isn't a tmp file system"
|
||||||
|
echo -e "\tplease add to your /etc/fstab file:\n\ttmpfs /tmp tmpfs defaults,noatime,nosuid 0 0"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
# Version: 0.2.0
|
# Version: 0.2.0
|
||||||
# Data: 11/Aug/2019
|
# Data: 11/Aug/2019
|
||||||
|
|
||||||
|
export TMPDIR=/tmp
|
||||||
|
|
||||||
RAINSENSOR_DEBOUNCE=0.3 # 0.3 seconds for manage debounce of reed contact
|
RAINSENSOR_DEBOUNCE=0.3 # 0.3 seconds for manage debounce of reed contact
|
||||||
|
|
||||||
RAINSENSORQTY_verbose="yes" # yes/no
|
RAINSENSORQTY_verbose="yes" # yes/no
|
||||||
@@ -15,9 +17,9 @@ RAINSENSORQTY_HISTORY="$STATUS_DIR/rainsensorqty_history"
|
|||||||
|
|
||||||
RAINSENSORQTY_MONITORLOG="$DIR_SCRIPT/log/rainsensorqty_monitor.log"
|
RAINSENSORQTY_MONITORLOG="$DIR_SCRIPT/log/rainsensorqty_monitor.log"
|
||||||
|
|
||||||
RAINSENSORQTY_MONPID="$TMP_PATH/rainsensorqty_monitor.pid"
|
RAINSENSORQTY_MONPID="$TMPDIR/rainsensorqty_monitor.pid"
|
||||||
RAINSENSORQTY_STATE="$TMP_PATH/rainsensorqty_state"
|
RAINSENSORQTY_STATE="$TMPDIR/rainsensorqty_state"
|
||||||
RAINSENSORQTY_STATE_HIST="$TMP_PATH/rainsensorqty_state.history"
|
RAINSENSORQTY_STATE_HIST="$TMPDIR/rainsensorqty_state.history"
|
||||||
|
|
||||||
RAINSENSORQTY_DIR="$DIR_SCRIPT/drv/rainsensorqty"
|
RAINSENSORQTY_DIR="$DIR_SCRIPT/drv/rainsensorqty"
|
||||||
|
|
||||||
@@ -41,8 +43,9 @@ config_check()
|
|||||||
var2check="RAINSENSOR_DEBOUNCE RAINSENSORQTY_verbose RAINSENSORQTY_LASTRAIN RAINSENSORQTY_HISTORY RAINSENSORQTY_MONITORLOG RAINSENSORQTY_MONPID RAINSENSORQTY_DIR monitor_sh"
|
var2check="RAINSENSOR_DEBOUNCE RAINSENSORQTY_verbose RAINSENSORQTY_LASTRAIN RAINSENSORQTY_HISTORY RAINSENSORQTY_MONITORLOG RAINSENSORQTY_MONPID RAINSENSORQTY_DIR monitor_sh"
|
||||||
for var in $var2check
|
for var in $var2check
|
||||||
do
|
do
|
||||||
if [[ -z $var ]] ; then
|
#${!a}
|
||||||
echo "ERROR: $var not set"
|
if [[ -z ${!var} ]] ; then
|
||||||
|
echo "ERROR: \$$var not set"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -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.1
|
# Version: 0.2.2
|
||||||
# Data: 29/Aug/2019
|
# Data: 08/Sep/2019
|
||||||
|
|
||||||
resetcounter()
|
resetcounter()
|
||||||
{
|
{
|
||||||
@@ -20,15 +20,12 @@ resetcounter()
|
|||||||
|
|
||||||
trap "resetcounter" SIGUSR1
|
trap "resetcounter" SIGUSR1
|
||||||
|
|
||||||
|
|
||||||
DIRNAME="$( dirname $0 )"
|
DIRNAME="$( dirname $0 )"
|
||||||
f="$(basename $0)"
|
f="$(basename $0)"
|
||||||
. $DIRNAME/common.include.sh
|
. $DIRNAME/common.include.sh
|
||||||
TMP_PATH="/run/shm"
|
|
||||||
if [ ! -d "$TMP_PATH" ]; then
|
|
||||||
TMP_PATH="/tmp"
|
|
||||||
fi
|
|
||||||
|
|
||||||
RAINSENSORQTY_VAR=$TMP_PATH/.rainsensorqty_var
|
RAINSENSORQTY_VAR=$TMPDIR/.rainsensorqty_var
|
||||||
|
|
||||||
if [[ -f "$RAINSENSORQTY_VAR" ]] ; then
|
if [[ -f "$RAINSENSORQTY_VAR" ]] ; then
|
||||||
en_echo "NORMAL: file $RAINSENSORQTY_VAR found - getting variables"
|
en_echo "NORMAL: file $RAINSENSORQTY_VAR found - getting variables"
|
||||||
@@ -60,7 +57,7 @@ MMEACH="$RAINSENSORQTY_MMEACH"
|
|||||||
rain_history
|
rain_history
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
en_echo "---- NEW RUN "
|
en_echo "---- NEW RUN ----"
|
||||||
|
|
||||||
# loop forever
|
# loop forever
|
||||||
while true
|
while true
|
||||||
@@ -74,8 +71,8 @@ do
|
|||||||
if (( elapsed >= RAINSENSORQTY_SECSBETWEENRAINEVENT )) ; then
|
if (( elapsed >= RAINSENSORQTY_SECSBETWEENRAINEVENT )) ; then
|
||||||
(( counter=0 ))
|
(( counter=0 ))
|
||||||
drv_rainsensorqty_writelog $f "first drops after $elapsed seconds since last rain ( greater than $RAINSENSORQTY_SECSBETWEENRAINEVENT )- new cycle - waiting for $( $JQ -n "$RAINSENSORQTY_LOOPSFORSETRAINING * $MMEACH" ) mm of rain" &
|
drv_rainsensorqty_writelog $f "first drops after $elapsed seconds since last rain ( greater than $RAINSENSORQTY_SECSBETWEENRAINEVENT )- new cycle - waiting for $( $JQ -n "$RAINSENSORQTY_LOOPSFORSETRAINING * $MMEACH" ) mm of rain" &
|
||||||
echo "NEW CYCLE"
|
en_echo "---- NEW CYCLE ----"
|
||||||
rain_history
|
rain_history &
|
||||||
fi
|
fi
|
||||||
(( counter+=1 ))
|
(( counter+=1 ))
|
||||||
en_echo "$RAINSENSORQTY_PULSE PULSE #$counter RECEIVED"
|
en_echo "$RAINSENSORQTY_PULSE PULSE #$counter RECEIVED"
|
||||||
|
|||||||
@@ -24,10 +24,14 @@ function drv_rainsensorqty_init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ! config_check ; then
|
if ! config_check ; then
|
||||||
echo "ERROR"
|
echo "ERROR in config_check function"
|
||||||
exit 1
|
exit 1
|
||||||
|
else
|
||||||
|
: #echo "config_check ok"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
RAINSENSORQTY_VAR=$TMP_PATH/.rainsensorqty_var
|
check_TMPDIR
|
||||||
|
|
||||||
|
RAINSENSORQTY_VAR=$TMPDIR/.rainsensorqty_var
|
||||||
|
|
||||||
set | $GREP -e ^GPIO -e ^LOG -e ^CUT -e ^JQ -e ^RAIN -e ^SCR -e ^TMP > $RAINSENSORQTY_VAR
|
set | $GREP -e ^GPIO -e ^LOG -e ^CUT -e ^JQ -e ^RAIN -e ^SCR -e ^TMP > $RAINSENSORQTY_VAR
|
||||||
|
|||||||
Reference in New Issue
Block a user