-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdump1090-controller.sh
137 lines (114 loc) · 4.21 KB
/
dump1090-controller.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
# Copyright (c) 2019 by Philip Collier, radio AB9IL <webmaster@ab9il.net>
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version. There is NO warranty; not even for
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# Capture, decode, and save ADS-B data.
#Get the SDR frequency offset (ppm)
ppm=$(cat /usr/local/etc/sdr_offset)
#Get the SDR gain (gain)
gain=$(cat /usr/local/etc/sdr_gain)
#Get the SoapySDR driver string
devdriver=$(cat /usr/local/etc/sdr_driver)
#Get the SoapySDR key number
devkey=$(cat /usr/local/etc/sdr_key)
#Get the receiver position
readarray -t devposition < /usr/local/etc/sdr_posn
fifo='/run/dump1090/1090.dump'
# define the rofi and fzf commands
ROFI_COMMAND1="rofi -dmenu -p Select -lines 5"
FZF_COMMAND1="fzf --layout=reverse --header=Select:"
startlog() {
# run dump1090
mkfifo -m 666 $fifo
rx_sdr -F CU8 -f 1090000000 -s 2048000 -p $ppm -g $gain -d driver=$devdriver','$devkey $fifo &
cat $fifo | dump1090 --net-sbs-port 30003 --fix &
nc 127.0.0.1 30003 | egrep --line-buffered 'MSG,1|MSG,3|MSG,4|MSG,6' >> $HOME/adsb.log &
}
start_decoded_log() {
# run dump1090
mkfifo -m 666 $fifo
rx_sdr -F CU8 -f 1090000000 -s 2048000 -p $ppm -g $gain -d driver=$devdriver','$devkey $fifo &
cat $fifo | dump1090 --net --net-sbs-port 30003 --fix &
/usr/local/bin/dump1090-stream-parser &
sqlitebrowser $HOME/adsb_messages.db &
}
startplot() {
# split the position into variables for latitude and longitude
latitude=$(echo $devposition | cut -f1 -d ",")
longitude=$(echo $devposition | cut -f2 -d ",")
cp /usr/local/share/dump1090/html/config.js.orig /usr/local/share/dump1090/html/config.js
# edit the config file with actual lat/lon
sed -i "
32s/.*/SiteLat = $latitude;/ ;
33s/.*/SiteLon = $longitude;/ ;
37s/.*/DefaultCenterLat = $latitude;/ ;
38s/.*/DefaultCenterLon = $longitude;/ ;" /usr/local/share/dump1090/html/config.js
# run dump1090
mkfifo -m 666 $fifo
rx_sdr -F CU8 -f 1090000000 -s 2048000 -p $ppm -g $gain -d driver=$devdriver','$devkey $fifo &
cat $fifo | dump1090 --net --net-sbs-port 30003 --write-json /run/dump1090 --fix &
# Open the map in firefox
firefox --new-tab http://localhost/dump1090/ &
# Start the stream parser
/usr/local/bin/dump1090-stream-parser &
}
notifyerror(){
echo "Something went wrong!!!!!!"
WINDOW=$(zenity --info --height 100 --width 350 \
--title="Dump1090 - Error." \
--text="Something went wrong!!!!!!");
stop_dump
exit
}
stop_dump(){
killall -9 dump1090 rx_sdr rtl_sdr rtl_tcp $(lsof -t -i:30003) sqlitebrowser
pkill -f /usr/local/bin/dump1090-stream-parser
find /run/dump1090/ -type p -delete
exit
}
sdr_params() {
sh -c "sdr-params.sh"
}
showhelp() {
echo "Dump1090 captures pulse modulated data from mode-s transponders
aboard aircraft.
Usage: $0 to start from the terminal.
$0 gui to start in Rofi.
Select the mode of data presentation.
Choices are:
- raw data dump to file
- store data in database
- present data on a map
Use the SDR Operating Parameters app to:
- enter your geographic coordinates for the map.
- set the SDR device gain
- set the device ppm offset corection
- set other device operating parameters
"
}
OPTIONS="Start Dump1090 and plot aircraft positions.
Start Dump1090 and write decoded data to a database.
Start Dump1090 and write raw data to a logfile.
Set your geograpgic location or device parameters.
Stop Dump1090."
case "$1" in
"")
COMMAND1=$FZF_COMMAND1
;;
"gui")
COMMAND1=$ROFI_COMMAND1
;;
*)
showhelp
;;
esac
# Take the choice; exit if no answer matches options.
REPLY="$(echo -e "$OPTIONS" | $COMMAND1 )"
[[ "$REPLY" == "Start Dump1090 and plot aircraft positions." ]] && startplot
[[ "$REPLY" == "Start Dump1090 and write decoded data to a database." ]] && start_decoded_log
[[ "$REPLY" == "Start Dump1090 and write raw data to a logfile." ]] && startlog
[[ "$REPLY" == "Stop Dump1090." ]] && stop_dump
[[ "$REPLY" == "Set your geograpgic location or device parameters." ]] && sdr_params