forked from kazikcz/ath9k-spectral-scan
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathss
executable file
·78 lines (68 loc) · 1.8 KB
/
ss
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
#!/bin/sh
max_samples=15000
plot_pause=0.05
host=$1
# The function gathers the binary spectral scan data and outputs it.
# Each packet looks like this:
# <number>\n
# <base64 line 1>\n
# <base64 line ..>\n
# .\n
spectral_scan() {
cat << 'EOF' | ssh $host sh
ifconfig wlan0 up
while true
do
for i in $(seq 1 100)
do
echo $i
echo chanscan \
| tee /sys/kernel/debug/ieee80211/phy*/ath9k/spectral_scan_ctl \
>/dev/null
# original scan code:
# iw wlan0 scan chan-time 5
# quicker scanning with limited channels:
iw wlan0 scan freq 2412 2422 2432 2442 2452 2462 passive >/dev/null
cat /sys/kernel/debug/ieee80211/phy*/ath9k/spectral_scan0 | base64
echo .
done
done
EOF
}
# The function processes spectral_scan() data into human readable output and puts it into /tmp/fft.dump.all.
# Each time new data arrives it is appended and the oldest data is pruned regularly.
# The output file is intended to be read by gnupot.
process() {
while read i
do
echo $i
while read line
do
test "$line" = . && break
echo "$line"
done | base64 -d > /tmp/fft.dump.$i
cat /tmp/fft.dump.all > /tmp/fft.dump.all.new
./fft2txt < /tmp/fft.dump.$i | awk '{print $4 " " $6 " " $2}' >> /tmp/fft.dump.all.new
tail -n $max_samples < /tmp/fft.dump.all.new > /tmp/fft.dump.all.new.limited
mv /tmp/fft.dump.all.new.limited /tmp/fft.dump.all
# `mv` guarantees /tmp/fft.dump.all stays consistent
done
}
# Essential gnuplot real-time drawing config
cat << EOF > /tmp/gnuplot.conf
set terminal x11
set yrange [-128:0]
pause $plot_pause
replot
reread
EOF
gnuplot=
trap '
s=$?
trap - EXIT QUIT
kill -HUP $gnuplot
exit $s
' INT HUP KILL TERM EXIT QUIT
touch /tmp/fft.dump.all
gnuplot -persistent -e 'plot "/tmp/fft.dump.all" using 1:2:3 w p pt 1 lc variable' /tmp/gnuplot.conf & gnuplot=$!
spectral_scan | process