From 2056b30be0cd261621750610a8906f4725037004 Mon Sep 17 00:00:00 2001 From: lejubila Date: Wed, 16 Aug 2017 16:37:35 +0200 Subject: [PATCH] Variato emissione log chiamate alle callback dei driver --- conf/piGarden.conf.example | 3 +++ drv/sample/init.include.sh | 2 +- drv/sample/rainsensor.include.sh | 4 ++-- drv/sample/rele.include.sh | 6 +++--- drv/sample/supply.include.sh | 7 ++++--- include/drv.include.sh | 31 +++++++++++++++++++++---------- 6 files changed, 34 insertions(+), 19 deletions(-) diff --git a/conf/piGarden.conf.example b/conf/piGarden.conf.example index cc80bdf..72b70fa 100644 --- a/conf/piGarden.conf.example +++ b/conf/piGarden.conf.example @@ -2,6 +2,9 @@ LOG_FILE="/home/pi/piGarden/log/piGarden.log" LOG_FILE_MAX_SIZE=1048576 # 1MB +# Log file for driver output +LOG_OUTPUT_DRV_FILE="/tmp/piGarden.drv.log" + # Status directory STATUS_DIR="/home/pi/piGarden/state" diff --git a/drv/sample/init.include.sh b/drv/sample/init.include.sh index 0d0da6a..f1c3002 100644 --- a/drv/sample/init.include.sh +++ b/drv/sample/init.include.sh @@ -3,7 +3,7 @@ # function drv_sample_init { - echo "$(date) drv_sample_init" >> /tmp/piGarden.drv.sample + local FOO="bar" } diff --git a/drv/sample/rainsensor.include.sh b/drv/sample/rainsensor.include.sh index d805b5a..25fcd5c 100644 --- a/drv/sample/rainsensor.include.sh +++ b/drv/sample/rainsensor.include.sh @@ -5,7 +5,7 @@ # function drv_sample_rain_sensor_init { - echo "$(date) drv_sample_rain_sensor_init $1" >> /tmp/piGarden.drv.sample + local FOO="bar" } @@ -16,7 +16,7 @@ function drv_sample_rain_sensor_init { # function drv_sample_rain_sensor_get { - echo "$(date) drv_sample_rain_sensor_get $1" >> /tmp/piGarden.drv.sample + local FOO="bar" } diff --git a/drv/sample/rele.include.sh b/drv/sample/rele.include.sh index 424c658..51623ba 100644 --- a/drv/sample/rele.include.sh +++ b/drv/sample/rele.include.sh @@ -5,7 +5,7 @@ # function drv_sample_rele_init { - echo "$(date) drv_sample_rele_init $1" >> /tmp/piGarden.drv.sample + local FOO="bar" } @@ -16,7 +16,7 @@ function drv_sample_rele_init { # function drv_sample_rele_open { - echo "$(date) drv_sample_rele_open $1" >> /tmp/piGarden.drv.sample + local FOO="bar" } @@ -27,7 +27,7 @@ function drv_sample_rele_open { # function drv_sample_rele_close { - echo "$(date) drv_sample_rele_close $1" >> /tmp/piGarden.drv.sample + local FOO="bar" } diff --git a/drv/sample/supply.include.sh b/drv/sample/supply.include.sh index b83e203..2a74990 100644 --- a/drv/sample/supply.include.sh +++ b/drv/sample/supply.include.sh @@ -6,7 +6,8 @@ # function drv_sample_supply_bistable_init { - echo "$(date) drv_sample_supply_bistable_init $1 $2" >> /tmp/piGarden.drv.sample + local FOO="bar" + } # @@ -17,7 +18,7 @@ function drv_sample_supply_bistable_init { # function drv_sample_supply_positive { - echo "$(date) drv_sample_supply_positive $1 $2" >> /tmp/piGarden.drv.sample + local FOO="bar" } @@ -29,7 +30,7 @@ function drv_sample_supply_positive { # function drv_sample_supply_negative { - echo "$(date) drv_sample_supply_negative $1 $2" >> /tmp/piGarden.drv.sample + local FOO="bar" } diff --git a/include/drv.include.sh b/include/drv.include.sh index 811fd8b..cc577d2 100644 --- a/include/drv.include.sh +++ b/include/drv.include.sh @@ -85,7 +85,8 @@ function drv_rele_init { log_write "Driver not found: $idx" message_write "warning" "Driver not found: $idx" else - $fnc "$idx" + echo "$(date) $fnc arg:$idx" > "$LOG_OUTPUT_DRV_FILE" + $fnc "$idx" >> "$LOG_OUTPUT_DRV_FILE" 2>&1 fi } @@ -106,7 +107,8 @@ function drv_rele_close { log_write "Driver not found: $idx" message_write "warning" "Driver not found: $idx" else - $fnc "$idx" + echo "$(date) $fnc arg:$idx" >> "$LOG_OUTPUT_DRV_FILE" + $fnc "$idx" >> "$LOG_OUTPUT_DRV_FILE" 2>&1 fi } @@ -127,7 +129,8 @@ function drv_rele_open { log_write "Driver not found: $idx" message_write "warning" "Driver not found: $idx" else - $fnc "$idx" + echo "$(date) $fnc arg:$idx" >> "$LOG_OUTPUT_DRV_FILE" + $fnc "$idx" >> "$LOG_OUTPUT_DRV_FILE" 2>&1 fi } @@ -153,7 +156,8 @@ function drv_supply_bistable_init { message_write "warning" "Driver not found: $idx1" return else - $fnc1 "$idx1" + echo "$(date) $fnc1 arg:$idx1" >> "$LOG_OUTPUT_DRV_FILE" + $fnc1 "$idx1" >> "$LOG_OUTPUT_DRV_FILE" 2>&1 fi # Nessun driver definito, esegue l'operazione tramite gpio del raspberry @@ -165,7 +169,8 @@ function drv_supply_bistable_init { log_write "Driver not found: $idx2" message_write "warning" "Driver not found: $idx2" else - $fnc2 "$idx2" + echo "$(date) $fnc2 arg:$idx2" >> "$LOG_OUTPUT_DRV_FILE" + $fnc2 "$idx2" >> "$LOG_OUTPUT_DRV_FILE" 2>&1 fi } @@ -191,7 +196,8 @@ function drv_supply_positive { message_write "warning" "Driver not found: $idx1" return else - $fnc1 "$idx1" + echo "$(date) $fnc1 arg:$idx1" >> "$LOG_OUTPUT_DRV_FILE" + $fnc1 "$idx1" >> "$LOG_OUTPUT_DRV_FILE" 2>&1 fi # Nessun driver definito, esegue l'operazione tramite gpio del raspberry @@ -202,7 +208,8 @@ function drv_supply_positive { log_write "Driver not found: $idx2" message_write "warning" "Driver not found: $idx2" else - $fnc2 "$idx2" + echo "$(date) $fnc2 arg:$idx2" >> "$LOG_OUTPUT_DRV_FILE" + $fnc2 "$idx2" >> "$LOG_OUTPUT_DRV_FILE" 2>&1 fi } @@ -228,7 +235,8 @@ function drv_supply_negative { message_write "warning" "Driver not found: $idx1" return else - $fnc1 "$idx1" + echo "$(date) $fnc1 arg:$idx1" >> "$LOG_OUTPUT_DRV_FILE" + $fnc1 "$idx1" >> "$LOG_OUTPUT_DRV_FILE" 2>&1 fi # Nessun driver definito, esegue l'operazione tramite gpio del raspberry @@ -239,7 +247,8 @@ function drv_supply_negative { log_write "Driver not found: $idx2" message_write "warning" "Driver not found: $idx2" else - $fnc2 "$idx2" + echo "$(date) $fnc2 arg:$idx2" >> "$LOG_OUTPUT_DRV_FILE" + $fnc2 "$idx2" >> "$LOG_OUTPUT_DRV_FILE" 2>&1 fi } @@ -262,7 +271,8 @@ function drv_rain_sensor_init { log_write "Driver not found: $idx" message_write "warning" "Driver not found: $idx" else - $fnc "$idx" + echo "$(date) $fnc arg:$idx" >> "$LOG_OUTPUT_DRV_FILE" + $fnc "$idx" >> "$LOG_OUTPUT_DRV_FILE" 2>&1 fi } @@ -285,6 +295,7 @@ function drv_rain_sensor_get { log_write "Driver not found: $idx" message_write "warning" "Driver not found: $idx" else + echo "$(date) $fnc arg:$idx" >> "$LOG_OUTPUT_DRV_FILE" vret=`$fnc "$idx"` fi