iniziato gestione driver

This commit is contained in:
lejubila
2017-08-03 00:18:35 +02:00
parent 9cb7d6ce9d
commit 867b4e4374
8 changed files with 81 additions and 0 deletions

2
drv/sample/README.md Normal file
View File

@@ -0,0 +1,2 @@
# Fake driver for sample and testing

View 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
}

View 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
}

View 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
}

View 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

Binary file not shown.

33
include/drv.include.sh Normal file
View 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
}

View File

@@ -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)