CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/Frame_params/Parrot_Disco/gpio.sh
Views: 1799
1
#!/bin/sh
2
# this is a script triggered from GPIO changes. It is setup to take photos
3
# start/stop recording and start/stop streaming on a disco
4
5
PIN="$1"
6
VALUE="$2"
7
echo "got pin=$PIN value=$VALUE"
8
9
PATH=$PATH:/bin:/usr/bin:/data/ftp/internal_000/ardupilot
10
export PATH
11
12
cd /data/ftp/internal_000/ardupilot
13
14
if [ $PIN = 100 ]; then
15
# take photo when high
16
if [ $VALUE = 1 ]; then
17
echo "$(date) Taking picture" >> gpio.log
18
/usr/bin/pimpctl take-picture front
19
fi
20
fi
21
22
if [ $PIN = 101 ]; then
23
# recording start/stop
24
if [ $VALUE = 1 ]; then
25
echo "$(date) Starting recording" >> gpio.log
26
/usr/bin/pimpctl recording-start front
27
else
28
echo "$(date) Stopping recording" >> gpio.log
29
/usr/bin/pimpctl recording-stop front
30
fi
31
fi
32
33
if [ $PIN = 102 ]; then
34
GCS_IP=$(netstat -n|grep 14550 | head -1 | awk '{print $5}'| cut -d: -f1)
35
# streaming start/stop
36
if [ $VALUE = 1 ]; then
37
echo "$(date) Starting streaming to $GCS_IP 8888" >> gpio.log
38
/usr/bin/pimpctl stream-start front $GCS_IP 8888
39
else
40
echo "$(date) Stopping streaming to $GCS_IP 8888" >> gpio.log
41
/usr/bin/pimpctl stream-stop front $GCS_IP 8888
42
fi
43
fi
44
45