X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=x4%2Fsanity_check;h=036d4b99bcabf475329154c008f0ecd0dc0d9c39;hb=7c4d20a90d6b9ec4f3b11bdbc9d3930180b2b11e;hp=fea986c7b46b6b5fc2a6989e044f1ac30bf6d67e;hpb=4411059d155436af0e80e5e6c3928ac8373093d6;p=khatus.git diff --git a/x4/sanity_check b/x4/sanity_check index fea986c..036d4b9 100755 --- a/x4/sanity_check +++ b/x4/sanity_check @@ -6,11 +6,13 @@ set -e dir="${prefix}/${host}" -kill_sensor() { - if test -f "$1" - then - kill $(cat "$1") - fi +kill_all() { + for pid_file in $(find $dir -type f -name pid) + do + kill -9 $(cat $pid_file) || true + rm $pid_file + done + pkill khatus_x4 } read_sensor() { @@ -22,21 +24,18 @@ read_sensor() { fi } -kill_sensor ${dir}/khatus_x4_sensor_datetime/pid -kill_sensor ${dir}/khatus_x4_sensor_mpd/pid -kill_sensor ${dir}/khatus_x4_sensor_energy/pid +kill_all -./bin/khatus_x4_sensor_datetime -d -./bin/khatus_x4_sensor_mpd -d -./bin/khatus_x4_sensor_energy -d +./bin/khatus_x4_sensor_datetime & +./bin/khatus_x4_sensor_mpd & +./bin/khatus_x4_sensor_energy & while : do battery_state="$(read_sensor ${dir}/khatus_x4_sensor_energy/out/battery_state)" battery_percentage="$(read_sensor ${dir}/khatus_x4_sensor_energy/out/battery_percentage)" datetime="$(read_sensor ${dir}/khatus_x4_sensor_datetime/out/datetime)" - mpd="$(read_sensor ${dir}/khatus_x4_sensor_mpd/out/state)" - printf \ - "E[${battery_state} ${battery_percentage}] [${mpd}] ${datetime}\n" + mpd="$(read_sensor ${dir}/khatus_x4_sensor_mpd/out/status)" + echo "E[${battery_state} ${battery_percentage}] [${mpd}] ${datetime}" sleep 1 done