versione 0.2.3

This commit is contained in:
androtto
2019-09-21 23:00:50 +02:00
parent 0b34b7010f
commit 2add0c725f
13 changed files with 36 additions and 53 deletions

View File

@@ -69,9 +69,9 @@ RAINSENSORQTY_HISTORY="$STATUS_DIR/rainsensorqty_history"
RAINSENSORQTY_MONITORLOG="$DIR_SCRIPT/log/rainsensorqty_monitor.log"
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
RAINSENSORQTY_STATE="$TMP_PATH/rainsensorqty_state"
RAINSENSORQTY_STATE="$TMPDIR/rainsensorqty_state"
file che viene popolato con l'ultimo stato della vaschetta (formato timestamp:counter)
RAINSENSORQTY_DIR="$DIR_SCRIPT/drv/rainsensorqty"
@@ -79,7 +79,9 @@ RAINSENSORQTY_DIR="$DIR_SCRIPT/drv/rainsensorqty"
monitor_sh="$RAINSENSORQTY_DIR/drv_rainsensorqty_monitor.sh"
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
# pull-up/down if rain gauge is connected directly to raspberry

View File

View File

@@ -13,11 +13,6 @@ cd $SCRIPTDIR/.. # command is a subdirectory of driver
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
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"
. $CONFIG_ETC

View File

@@ -13,17 +13,12 @@ cd $SCRIPTDIR/.. # command is a subdirectory of driver
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
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"
. $CONFIG_ETC
. ./common.include.sh
. ./config.include.sh
. ./config.include.sh
. ./init.include.sh
. ./rainsensor.include.sh

View File

@@ -12,10 +12,6 @@ cd $SCRIPTDIR/.. # command is a subdirectory of driver
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
CONFIG_ETC="/etc/piGarden.conf"
TMP_PATH="/run/shm"
if [ ! -d "$TMP_PATH" ]; then
TMP_PATH="/tmp"
fi
. $CONFIG_ETC

View File

@@ -13,10 +13,6 @@ cd $SCRIPTDIR/.. # command is a subdirectory of driver
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
CONFIG_ETC="/etc/piGarden.conf"
TMP_PATH="/run/shm"
if [ ! -d "$TMP_PATH" ]; then
TMP_PATH="/tmp"
fi
. $CONFIG_ETC

View File

@@ -12,11 +12,6 @@ cd $SCRIPTDIR/.. # command is a subdirectory of driver
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
CONFIG_ETC="/etc/piGarden.conf"
TMP_PATH="/run/shm"
if [ ! -d "$TMP_PATH" ]; then
TMP_PATH="/tmp"
fi
. $CONFIG_ETC
. ./config.include.sh

View File

@@ -12,10 +12,6 @@ cd $SCRIPTDIR/.. # command is a subdirectory of driver
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
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"

View File

@@ -12,10 +12,6 @@ cd $SCRIPTDIR/.. # command is a subdirectory of driver
DIR_SCRIPT=/home/pi/piGarden # home directory of piGarden
CONFIG_ETC="/etc/piGarden.conf"
TMP_PATH="/run/shm"
if [ ! -d "$TMP_PATH" ]; then
TMP_PATH="/tmp"
fi
. $CONFIG_ETC

View File

@@ -8,7 +8,7 @@
#note:
#RAINSENSORQTY_MONPID="$TMP_PATH/rainsensorqty_monitor.pid"
#RAINSENSORQTY_MONPID="$TMPDIR/rainsensorqty_monitor.pid"
#
d() # short date & time
@@ -80,3 +80,11 @@ do
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
}

View File

@@ -6,6 +6,8 @@
# Version: 0.2.0
# Data: 11/Aug/2019
export TMPDIR=/tmp
RAINSENSOR_DEBOUNCE=0.3 # 0.3 seconds for manage debounce of reed contact
RAINSENSORQTY_verbose="yes" # yes/no
@@ -15,9 +17,9 @@ RAINSENSORQTY_HISTORY="$STATUS_DIR/rainsensorqty_history"
RAINSENSORQTY_MONITORLOG="$DIR_SCRIPT/log/rainsensorqty_monitor.log"
RAINSENSORQTY_MONPID="$TMP_PATH/rainsensorqty_monitor.pid"
RAINSENSORQTY_STATE="$TMP_PATH/rainsensorqty_state"
RAINSENSORQTY_STATE_HIST="$TMP_PATH/rainsensorqty_state.history"
RAINSENSORQTY_MONPID="$TMPDIR/rainsensorqty_monitor.pid"
RAINSENSORQTY_STATE="$TMPDIR/rainsensorqty_state"
RAINSENSORQTY_STATE_HIST="$TMPDIR/rainsensorqty_state.history"
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"
for var in $var2check
do
if [[ -z $var ]] ; then
echo "ERROR: $var not set"
#${!a}
if [[ -z ${!var} ]] ; then
echo "ERROR: \$$var not set"
exit 1
fi
done

View File

@@ -4,8 +4,8 @@
# Author: androtto
# file "drv_rainsensorqty_monitor.sh"
# monitor script
# Version: 0.2.1
# Data: 29/Aug/2019
# Version: 0.2.2
# Data: 08/Sep/2019
resetcounter()
{
@@ -20,15 +20,12 @@ resetcounter()
trap "resetcounter" SIGUSR1
DIRNAME="$( dirname $0 )"
f="$(basename $0)"
. $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
en_echo "NORMAL: file $RAINSENSORQTY_VAR found - getting variables"
@@ -60,7 +57,7 @@ MMEACH="$RAINSENSORQTY_MMEACH"
rain_history
echo ""
en_echo "---- NEW RUN "
en_echo "---- NEW RUN ----"
# loop forever
while true
@@ -74,8 +71,8 @@ do
if (( elapsed >= RAINSENSORQTY_SECSBETWEENRAINEVENT )) ; then
(( 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" &
echo "NEW CYCLE"
rain_history
en_echo "---- NEW CYCLE ----"
rain_history &
fi
(( counter+=1 ))
en_echo "$RAINSENSORQTY_PULSE PULSE #$counter RECEIVED"

View File

@@ -24,10 +24,14 @@ function drv_rainsensorqty_init {
}
if ! config_check ; then
echo "ERROR"
echo "ERROR in config_check function"
exit 1
else
: #echo "config_check ok"
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