-
Notifications
You must be signed in to change notification settings - Fork 0
/
bin_ardrone3_stop.sh
73 lines (61 loc) · 1.52 KB
/
bin_ardrone3_stop.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
source /bin/ardrone3_shell.sh
source /sbin/emmc_lib.sh
eMMC_is_mounted ${ARDRONE3_MOUNT_PATH}
mmcOK=$?
pipe="/tmp/.dragon-pipe-in"
pipe_msg="dragon_shutdown"
#redirect coredump to /tmp to avoid fake coredumps due to shutdown
echo "/tmp/core/%e.%p" > /proc/sys/kernel/core_pattern
# Shut down the GPS
echo '!' > /tmp/gps_debug &
# Shutdown Dragon Prog
echo "Shutdown Dragon" | logger -s -t "shutdown" -p user.info
pid=$(pidof dragon-prog)
if [ $? -eq 0 ]
then
# Send a message to Dragon for a clean stop
echo "Asking Dragon to stop..." | logger -s -t "shutdown" -p user.info
if [ -p $pipe ]
then
echo $pipe_msg > $pipe &
fi
i=0
# Wait for Dragon to stop
while kill -0 $pid 2> /dev/null; do
if [ $i -gt 3 ]
then
echo "Timeout" | logger -s -t "shutdown" -p user.info
break
fi
sleep 1
i=$(($i+1))
done
fi
# We timed out the clean stop. Kill Dragon.
pid=$(pidof dragon-prog)
if [ $? -eq 0 ]
then
killall -KILL dragon-prog
fi
if [ ${mmcOK} -eq 0 ]
then
# stopping all processes using eMMC
echo "Stopping users of eMMC" | logger -s -t "shutdown" -p user.info
eMMC_release ${ARDRONE3_MOUNT_PATH}
fi
# Synchronise filesystems
echo "Synchronise filesystems" | logger -s -t "shutdown" -p user.info
sync
echo "3" > /proc/sys/vm/drop_caches
# umount all filesystems
# umount eMMC
[ ${mmcOK} -eq 0 ] && eMMC_umount
# umount NAND flash partitions
umount /update
umount /data
umount /factory
# remount / as read-only
mount -o remount,ro /
# Script to reboot the ardrone3 clean
bcmwl reboot