Run sanity_check sensors as children and pre-kill all existing
[khatus.git] / x4 / sanity_check
CommitLineData
4411059d
SK
1#! /bin/sh
2
3set -e
4
5. ./bin/khatus_x4_lib_common_sensor.sh
6
7dir="${prefix}/${host}"
8
7c4d20a9
SK
9kill_all() {
10 for pid_file in $(find $dir -type f -name pid)
11 do
12 kill -9 $(cat $pid_file) || true
13 rm $pid_file
14 done
15 pkill khatus_x4
4411059d
SK
16}
17
18read_sensor() {
19 if test -f "$1"
20 then
21 cat "$1"
22 else
23 printf '%s\n' '--'
24 fi
25}
26
7c4d20a9 27kill_all
4411059d 28
7c4d20a9
SK
29./bin/khatus_x4_sensor_datetime &
30./bin/khatus_x4_sensor_mpd &
31./bin/khatus_x4_sensor_energy &
4411059d
SK
32
33while :
34do
35 battery_state="$(read_sensor ${dir}/khatus_x4_sensor_energy/out/battery_state)"
36 battery_percentage="$(read_sensor ${dir}/khatus_x4_sensor_energy/out/battery_percentage)"
37 datetime="$(read_sensor ${dir}/khatus_x4_sensor_datetime/out/datetime)"
81f81623
SK
38 mpd="$(read_sensor ${dir}/khatus_x4_sensor_mpd/out/status)"
39 echo "E[${battery_state} ${battery_percentage}] [${mpd}] ${datetime}"
4411059d
SK
40 sleep 1
41done
This page took 0.021962 seconds and 4 git commands to generate.