summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSai Sree Kartheek Adivi2022-05-24 23:32:23 -0500
committerSai Sree Kartheek Adivi2022-05-24 23:32:23 -0500
commit103cd0700c60874b01230bea290383b6b385d09a (patch)
tree32d5e8b605171aaa9b341e8816aed6a64fff67d6
parentf1f08727d891361a3bcf8387e15bbe9e9b4230fd (diff)
downloadhmi-demo-103cd0700c60874b01230bea290383b6b385d09a.tar.gz
hmi-demo-103cd0700c60874b01230bea290383b6b385d09a.tar.xz
hmi-demo-103cd0700c60874b01230bea290383b6b385d09a.zip
scripts: Add launch scripts
Add launch/service scripts for launching HMI Demo, Matrix GUI and 3D Demos. Signed-off-by: Sai Sree Kartheek Adivi <s-adivi@ti.com>
-rw-r--r--scripts/start_3d_demo.sh15
-rwxr-xr-xscripts/start_hmi_matrix.sh79
2 files changed, 94 insertions, 0 deletions
diff --git a/scripts/start_3d_demo.sh b/scripts/start_3d_demo.sh
new file mode 100644
index 0000000..ec8006c
--- /dev/null
+++ b/scripts/start_3d_demo.sh
@@ -0,0 +1,15 @@
1#!/bin/sh
2
3DEMO_3D_APP_NAME=/usr/bin/SGX/demos/Wayland/OpenGLESSkinning
4
5# Get logical Width of the screen using weston-info
6eval `weston-info | grep 'logical_width\|logical_height' | sed -e 's/.*logical_width: \(.*\), logical_height: \(.*\)/LOGICAL_WIDTH=\1/'`
7
8# Get logical Height of the screen using weston-info
9eval `weston-info | grep 'logical_width\|logical_height' | sed -e 's/.*logical_width: \(.*\), logical_height: \(.*\)/LOGICAL_HEIGHT=\2/'`
10
11DEMO_3D_CMD="$DEMO_3D_APP_NAME -width=$LOGICAL_WIDTH -height=$LOGICAL_HEIGHT "
12
13# Launch 3D Demo
14eval $DEMO_3D_CMD
15
diff --git a/scripts/start_hmi_matrix.sh b/scripts/start_hmi_matrix.sh
new file mode 100755
index 0000000..a107718
--- /dev/null
+++ b/scripts/start_hmi_matrix.sh
@@ -0,0 +1,79 @@
1#!/bin/sh
2
3### BEGIN INIT INFO
4# Provides: HMI Demo
5### END INIT INFO
6
7APP=/usr/bin/hmi_demo
8MATRIX_LAUNCH_SCRIPT=/etc/init.d/matrix-gui-2.0
9DEMO_3D_LAUNCH_SCRIPT="/etc/init.d/start_3d_demo.sh"
10PIDFILE=/var/run/hmi_demo.pid
11LOGFILE=/var/log/hmi_demo.log
12
13start() {
14 # check if hmi-demo is already running
15 if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then
16 echo 'Service already running' >&2
17 return 1
18 fi
19
20 echo 'Starting HMI Demo ..' >&2
21
22 # setup XDG_RUNTIME_DIR if not already done
23 if test -z "$XDG_RUNTIME_DIR"; then
24 export XDG_RUNTIME_DIR=/tmp/`id -u`-runtime-dir
25 if ! test -d "$XDG_RUNTIME_DIR"; then
26 mkdir --parents $XDG_RUNTIME_DIR
27 chmod 0700 $XDG_RUNTIME_DIR
28 fi
29 fi
30
31 # wait for weston
32 while [ ! -e $XDG_RUNTIME_DIR/wayland-0 ] ; do sleep 0.1; done
33 export DISPLAY=:0.0
34
35 local HMI_EXIT_CODE=-1
36
37 while [ $HMI_EXIT_CODE -ne 0 ]; do
38 # Launch HMI Demo and save the PID
39 local CMD="$APP &> $LOGFILE & echo \$!"
40 eval $CMD > $PIDFILE
41
42 # wait until hmi exits
43 wait `cat $PIDFILE`
44 HMI_EXIT_CODE=$?
45
46 # try to stop the hmi_demo to mark the status as stopped
47 systemctl stop hmi_demo
48
49 echo "HMI Demo exited with $HMI_EXIT_CODE"
50 if [ `printf '%X' $HMI_EXIT_CODE` == "3D" ]; then
51 eval $DEMO_3D_LAUNCH_SCRIPT
52 else
53 # Launch Matrix GUI
54 local MATRIX_CMD="$MATRIX_LAUNCH_SCRIPT stop; $MATRIX_LAUNCH_SCRIPT start"
55 eval $MATRIX_CMD
56 fi
57 done
58}
59
60stop() {
61 if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
62 echo 'Service not running' >&2
63 return 1
64 fi
65 echo 'Stopping HMI Demo ..' >&2
66 kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
67}
68
69case "$1" in
70 start )
71 start
72 ;;
73 stop )
74 stop
75 ;;
76 * )
77 echo "Usage: $0 {start|stop|restart}"
78esac
79