iniziato gestione driver
This commit is contained in:
2
drv/sample/README.md
Normal file
2
drv/sample/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# Fake driver for sample and testing
|
||||
|
||||
11
drv/sample/close.include.sh
Normal file
11
drv/sample/close.include.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Questa funzione viene richiamata da "ev_close" di piGarden
|
||||
#
|
||||
# $1 identificativo relè da chiudere
|
||||
#
|
||||
function drv_sample_close {
|
||||
|
||||
echo "$(date) drv_sample_close $1" >> /tmp/piGarden.drv.sample
|
||||
|
||||
}
|
||||
|
||||
9
drv/sample/init.include.sh
Normal file
9
drv/sample/init.include.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Questa funzione viene inviocata dalla funzione "init" di piGarden se sono presenti elettrovalvole o sensori che utilizzano questo driver
|
||||
#
|
||||
function drv_sample_init {
|
||||
|
||||
echo "$(date) drv_sample_init" >> /tmp/piGarden.drv.sample
|
||||
|
||||
}
|
||||
|
||||
11
drv/sample/open.include.sh
Normal file
11
drv/sample/open.include.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Questa funzione viene richiamata da "ev_open" di piGarden
|
||||
#
|
||||
# $1 identificativo relè da aprire
|
||||
#
|
||||
function drv_sample_open {
|
||||
|
||||
echo "$(date) drv_sample_open $1" >> /tmp/piGarden.drv.sample
|
||||
|
||||
}
|
||||
|
||||
11
drv/sample/status.include.sh
Normal file
11
drv/sample/status.include.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Questa funzione viene richiamata da "ev_get_status" di piGarden
|
||||
#
|
||||
# $1 identificativo relè di cui repereire lo stato
|
||||
#
|
||||
function drv_sample_status {
|
||||
|
||||
echo "$(date) drv_sample_status $1" >> /tmp/piGarden.drv.sample
|
||||
|
||||
}
|
||||
|
||||
BIN
include/.drv.include.sh.swp
Normal file
BIN
include/.drv.include.sh.swp
Normal file
Binary file not shown.
33
include/drv.include.sh
Normal file
33
include/drv.include.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
function setup_drv {
|
||||
|
||||
declare -a list_drv
|
||||
list_drv=()
|
||||
|
||||
# Inizializza i driver per le elettrovalvole
|
||||
for i in $(seq $EV_TOTAL)
|
||||
do
|
||||
local a=EV"$i"_GPIO
|
||||
local gpio="${!a}"
|
||||
if [[ "$gpio" == drv:* ]]; then
|
||||
local drv=`echo $gpio | $CUT -d':' -f2,2`
|
||||
if [[ ! " ${list_drv[@]} " =~ " ${drv} " ]]; then
|
||||
list_drv+=("$drv")
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
local file_drv
|
||||
for drv in "${list_drv[@]}"
|
||||
do
|
||||
for callback in init open close status
|
||||
do
|
||||
file_drv="$DIR_SCRIPT/drv/$drv/$callback.include.sh"
|
||||
if [ -f "$file_drv" ]; then
|
||||
. "$file_drv"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
}
|
||||
@@ -1518,6 +1518,9 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. "$DIR_SCRIPT/include/drv.include.sh"
|
||||
|
||||
|
||||
LAST_INFO_FILE="$STATUS_DIR/last_info"
|
||||
LAST_WARNING_FILE="$STATUS_DIR/last_worning"
|
||||
LAST_SUCCESS_FILE="$STATUS_DIR/last_success"
|
||||
@@ -1534,6 +1537,7 @@ if [ -f "$LOCK_FILE" ]; then
|
||||
fi
|
||||
|
||||
send_identifier &
|
||||
setup_drv
|
||||
|
||||
case "$1" in
|
||||
init)
|
||||
|
||||
Reference in New Issue
Block a user