Aggiornato driver rainsensorqty alla versione 0.2.0
This commit is contained in:
40
drv/rainsensorqty/commands/rainsensorqty_CHECK.sh
Executable file
40
drv/rainsensorqty/commands/rainsensorqty_CHECK.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Driver rainsensorqty - driver for measure the rain volume
|
||||
# Author: androtto
|
||||
# file "test_rainsensorqty_CHECK.sh"
|
||||
# test script for checking rain status using drv_rainsensorqty_rain_sensor_get function
|
||||
# Version: 0.2.0
|
||||
# Data: 11/Aug/2019
|
||||
|
||||
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"
|
||||
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
|
||||
. ./init.include.sh
|
||||
. ./rainsensor.include.sh
|
||||
|
||||
# restituisce 0 se piove, e nell'output di testo il valore di "$RAIN_GPIO_STATE"
|
||||
# restituisce 99 se non piove, output "norain"
|
||||
# esce con 1 se non c'e' il monitoring, output "ERROR"
|
||||
|
||||
drv_rainsensorqty_rain_sensor_get
|
||||
case $? in
|
||||
0) echo "NORMAL: it's raining" ;;
|
||||
99) echo "NORMAL: it's not raining" ;;
|
||||
1) echo "ERROR: monitor process $DIR_SCRIPT/drv/rainsensorqty/drv_rainsensorqty_monitor.sh is not running" ;;
|
||||
esac
|
||||
|
||||
40
drv/rainsensorqty/commands/rainsensorqty_HISTORY.sh
Executable file
40
drv/rainsensorqty/commands/rainsensorqty_HISTORY.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Driver rainsensorqty - driver for measure the rain volume
|
||||
# Author: androtto
|
||||
# file "test_rainsensorqty_CHECK.sh"
|
||||
# test script for checking rain status using drv_rainsensorqty_rain_sensor_get function
|
||||
# Version: 0.2.0
|
||||
# Data: 11/Aug/2019
|
||||
|
||||
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"
|
||||
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
|
||||
. ./init.include.sh
|
||||
. ./rainsensor.include.sh
|
||||
|
||||
echo "RAIN HISTORY"
|
||||
rain_history
|
||||
|
||||
cat $RAINSENSORQTY_HISTORY | while read line
|
||||
do
|
||||
set -- ${line//:/ }
|
||||
when=$1
|
||||
howmuch=$2
|
||||
printf "RAINED on %s for %.2f mm\n" "$(date --date="@$1")" $( $JQ -n "$howmuch * $RAINSENSORQTY_MMEACH" )
|
||||
done
|
||||
|
||||
29
drv/rainsensorqty/commands/rainsensorqty_INIT.sh
Executable file
29
drv/rainsensorqty/commands/rainsensorqty_INIT.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
# Driver rainsensorqty - driver for measure the rain volume
|
||||
# Author: androtto
|
||||
# file "test_rainsensorqty_INIT.sh"
|
||||
# test script for initialize driver and executing monitor process
|
||||
# Version: 0.2.0
|
||||
# Data: 11/Aug/2019
|
||||
|
||||
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"
|
||||
TMP_PATH="/run/shm"
|
||||
if [ ! -d "$TMP_PATH" ]; then
|
||||
TMP_PATH="/tmp"
|
||||
fi
|
||||
|
||||
. $CONFIG_ETC
|
||||
|
||||
. ./config.include.sh
|
||||
. ./common.include.sh
|
||||
. ./init.include.sh
|
||||
. ./rainsensor.include.sh
|
||||
|
||||
drv_rainsensorqty_rain_sensor_init
|
||||
|
||||
drv_rainsensorqty_init
|
||||
48
drv/rainsensorqty/commands/rainsensorqty_KILL.sh
Executable file
48
drv/rainsensorqty/commands/rainsensorqty_KILL.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
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"
|
||||
TMP_PATH="/run/shm"
|
||||
if [ ! -d "$TMP_PATH" ]; then
|
||||
TMP_PATH="/tmp"
|
||||
fi
|
||||
|
||||
. $CONFIG_ETC
|
||||
|
||||
. ./config.include.sh
|
||||
. ./common.include.sh
|
||||
. ./init.include.sh
|
||||
. ./rainsensor.include.sh
|
||||
|
||||
# check if rain monitor process is running...
|
||||
if [[ -f "$RAINSENSORQTY_MONPID" ]] ; then
|
||||
pid="$( < "$RAINSENSORQTY_MONPID" )"
|
||||
if ps -fp $pid >/dev/null ; then
|
||||
echo "process $pid pid and its child(ren)"
|
||||
children_pid="$(ps -ef| awk "\$3==$pid {print \$2}")"
|
||||
ps -fp $pid
|
||||
ps -fp $children_pid | tail +2
|
||||
echo -e "\nsending TERM signal to $pid and its child(ren)"
|
||||
echo kill $children_pid
|
||||
echo kill $pid
|
||||
kill $children_pid
|
||||
kill $pid
|
||||
echo -e "\nchecking $pid pid and its child(ren) are still alive"
|
||||
for process in $pid $children_pid
|
||||
do
|
||||
if ps -fp $process >/dev/null ; then
|
||||
echo "$process is still alive"
|
||||
else
|
||||
echo "$process is dead"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "no RAIN process alive"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
27
drv/rainsensorqty/commands/rainsensorqty_RAINNOW.sh
Executable file
27
drv/rainsensorqty/commands/rainsensorqty_RAINNOW.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
# Driver rainsensorqty - driver for measure the rain volume
|
||||
# Author: androtto
|
||||
# file "test_rainsensorqty_RAINNOW.sh"
|
||||
# test script for simulate rain ... now!
|
||||
# Version: 0.2.0
|
||||
# Data: 11/Aug/2019
|
||||
|
||||
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"
|
||||
TMP_PATH="/run/shm"
|
||||
if [ ! -d "$TMP_PATH" ]; then
|
||||
TMP_PATH="/tmp"
|
||||
fi
|
||||
|
||||
. $CONFIG_ETC
|
||||
|
||||
. ./config.include.sh
|
||||
. ./common.include.sh
|
||||
. ./init.include.sh
|
||||
. ./rainsensor.include.sh
|
||||
|
||||
echo "$(date +%s):$RAINSENSORQTY_LOOPSFORSETRAINING" > ${RAINSENSORQTY_LASTRAIN}
|
||||
Reference in New Issue
Block a user