Commit caa5a5a5 authored by Christophe Massiot's avatar Christophe Massiot

* extra/dvbiscovery: New shell script which allows to guess which network we are on.

parent 42830b6a
About DVBiscovery
=================
DVBiscovery is a shell script that tries to tune a number of frequencies
(from a config file), and stops after it has found a match. It then dumps
the output of DVBlast to the standard output, so that an external process
can parse it and find relevant information there. Typically, you would
want to get the network ID from the NIT, which unically identifies the
network you are on.
DVBiscovery is therefore a sort of scanning program, but doesn't aim at
exhaustivity (there are already programs doing that). It tries to guess
where you are without any external information.
#!/bin/sh
###############################################################################
# dvbiscovery.sh
###############################################################################
# Copyright (C) 2010 VideoLAN
# $Id$
#
# Authors: Christophe Massiot <massiot@via.ecp.fr>
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
###############################################################################
CONF_BASE="/usr/local/share/dvblast/dvbiscovery-"
#CONF_BASE="./"
DVBLAST=dvblast
LOCK_TIMEOUT=2500
QUIT_TIMEOUT=15000
usage() {
echo "Usage: $0 [-a <adapter #>] [-S <diseqc sat num>] [-c <conf file>]" >&2
exit 1
}
conf_file_passed=""
adapter=""
diseqc=""
TEMP=`getopt -o a:S:c: -n "$0" -- "$@"`
if test $? -ne 0; then
usage
fi
eval set -- "$TEMP"
while :; do
case "$1" in
-a)
adapter="-a $2"
shift 2
;;
-c)
conf_file_passed=$2
shift 2
;;
-S)
diseqc="-S $2"
shift 2
;;
--)
shift
break
;;
*)
usage
;;
esac
done
type=`$DVBLAST $diseqc $adapter -f 0 2>&1 | grep '^debug: Frontend' | sed 's/^debug: Frontend ".*" type "\(.*\)" supports:$/\1/'`
tune=""
conf_file=""
case "$type" in
"QPSK (DVB-S/S2)")
conf_file="${CONF_BASE}_dvb-s.conf"
tune=tune_sat
;;
"QAM (DVB-C)")
conf_file="${CONF_BASE}_dvb-c.conf"
tune=tune_cable
;;
"OFDM (DVB-T)")
conf_file="${CONF_BASE}_dvb-t.conf"
tune=tune_dtt
;;
"ATSC")
conf_file="${CONF_BASE}_atsc.conf"
tune=tune_atsc
;;
*)
echo "unknown frontend type $type" >&2
exit 1
esac
if test -n "$conf_file_passed"; then
conf_file=$conf_file_passed
fi
if ! test -r "$conf_file"; then
echo "unable to open $conf_file" >&2
exit 1
fi
signal_catch() {
if test $childpid -ne 0; then
kill $childpid
fi
exit 1
}
exec_dvblast() {
tmp_file=`mktemp`
$DVBLAST $diseqc $adapter -O $LOCK_TIMEOUT -Q $QUIT_TIMEOUT $opts 2>| $tmp_file &
childpid=$!
wait $childpid
if test $? -eq 0; then
cat $tmp_file
rm $tmp_file
exit 0
fi
childpid=0
rm $tmp_file
}
strtofec() {
case "$1" in
"NONE") opts="$opts $2 0" ;;
"1/2") opts="$opts $2 12" ;;
"2/3") opts="$opts $2 23" ;;
"3/4") opts="$opts $2 34" ;;
"4/5") opts="$opts $2 45" ;;
"5/6") opts="$opts $2 56" ;;
"6/7") opts="$opts $2 67" ;;
"7/8") opts="$opts $2 78" ;;
"8/9") opts="$opts $2 89" ;;
"AUTO"|*) ;;
esac
}
strtomod() {
case "$1" in
"QPSK") opts="$opts -m qpsk" ;;
"QAM16") opts="$opts -m qam_16" ;;
"QAM32") opts="$opts -m qam_32" ;;
"QAM64") opts="$opts -m qam_64" ;;
"QAM128") opts="$opts -m qam_128" ;;
"8VSB") opts="$opts -m vsb_8" ;;
"16VSB") opts="$opts -m vsb_16" ;;
"AUTO"|*) ;;
esac
}
tune_sat() {
childpid=0
trap signal_catch 1 2 3 15
while read sys freq pol srate fec what mod; do
opts="-f $freq -s $srate"
case "$sys" in
"S") ;;
"S2")
case "$mod" in
"QPSK") opts="$opts -m qpsk" ;;
"8PSK") opts="$opts -m psk_8" ;;
*)
echo "invalid modulation $mod" >&2
;;
esac
;;
*)
echo "incompatible file" >&2
exit 1
;;
esac
strtofec $fec "-F"
case "$pol" in
"V") opts="$opts -v 13" ;;
"H") opts="$opts -v 18" ;;
*) ;;
esac
exec_dvblast
done
}
tune_cable() {
childpid=0
trap signal_catch 1 2 3 15
while read sys freq srate fec mod; do
opts="-f $freq -s $srate"
case "$sys" in
"C") ;;
*)
echo "incompatible file" >&2
exit 1
;;
esac
strtofec $fec "-F"
strtomod $mod
exec_dvblast
done
}
tune_dtt() {
childpid=0
trap signal_catch 1 2 3 15
while read sys freq bw fec fec2 mod mode guard hier; do
opts="-f $freq"
case "$sys" in
"T"|"T2") ;;
*)
echo "incompatible file" >&2
exit 1
;;
esac
case "$bw" in
"8MHz") opts="$opts -b 8" ;;
"7MHz") opts="$opts -b 7" ;;
"6MHz") opts="$opts -b 6" ;;
"AUTO"|*) ;;
esac
strtofec $fec "-F"
strtofec $fec2 "-K"
strtomod $mod
case "$mode" in
"2k") opts="$opts -X 2" ;;
"8k") opts="$opts -X 8" ;;
"AUTO"|*) ;;
esac
case "$guard" in
"1/32") opts="$opts -G 32" ;;
"1/16") opts="$opts -G 16" ;;
"1/8") opts="$opts -G 8" ;;
"1/4") opts="$opts -G 4" ;;
"AUTO"|*) ;;
esac
case "$hier" in
"NONE") opts="$opts -H 0" ;;
"1") opts="$opts -H 1" ;;
"2") opts="$opts -H 2" ;;
"4") opts="$opts -H 4" ;;
"AUTO"|*) ;;
esac
exec_dvblast
done
}
tune_atsc() {
childpid=0
trap signal_catch 1 2 3 15
while read sys freq mod; do
opts="-f $freq"
case "$sys" in
"A") ;;
*)
echo "incompatible file" >&2
exit 1
;;
esac
strtomod $mod
exec_dvblast
done
}
childpid=0
trap signal_catch 1 2 3 15
grep -v "^#" < "$conf_file" 2>/dev/null | $tune &
childpid=$!
wait $childpid
exit 100
# US ATSC center frequencies
A 57028615 8VSB
A 63028615 8VSB
A 69028615 8VSB
A 79028615 8VSB
A 85028615 8VSB
A 177028615 8VSB
A 183028615 8VSB
A 189028615 8VSB
A 195028615 8VSB
A 201028615 8VSB
A 207028615 8VSB
A 213028615 8VSB
A 473028615 8VSB
A 479028615 8VSB
A 485028615 8VSB
A 491028615 8VSB
A 497028615 8VSB
A 503028615 8VSB
A 509028615 8VSB
A 515028615 8VSB
A 521028615 8VSB
A 527028615 8VSB
A 533028615 8VSB
A 539028615 8VSB
A 545028615 8VSB
A 551028615 8VSB
A 557028615 8VSB
A 563028615 8VSB
A 569028615 8VSB
A 575028615 8VSB
A 581028615 8VSB
A 587028615 8VSB
A 593028615 8VSB
A 599028615 8VSB
A 605028615 8VSB
A 611028615 8VSB
A 617028615 8VSB
A 623028615 8VSB
A 629028615 8VSB
A 635028615 8VSB
A 641028615 8VSB
A 647028615 8VSB
A 653028615 8VSB
A 659028615 8VSB
A 665028615 8VSB
A 671028615 8VSB
A 677028615 8VSB
A 683028615 8VSB
A 689028615 8VSB
A 695028615 8VSB
A 701028615 8VSB
A 707028615 8VSB
A 713028615 8VSB
A 719028615 8VSB
A 725028615 8VSB
A 731028615 8VSB
A 737028615 8VSB
A 743028615 8VSB
A 749028615 8VSB
A 755028615 8VSB
A 761028615 8VSB
A 767028615 8VSB
A 773028615 8VSB
A 779028615 8VSB
A 785028615 8VSB
A 791028615 8VSB
A 797028615 8VSB
A 803028615 8VSB
# Gathered from diverse sources
C 113000000 6900000 NONE AUTO
C 121000000 6900000 NONE AUTO
C 123000000 6875000 NONE AUTO
C 146000000 6900000 NONE AUTO
C 154000000 6875000 NONE AUTO
C 154000000 6900000 NONE AUTO
C 163000000 6875000 NONE AUTO
C 218000000 6900000 NONE AUTO
C 241000000 6900000 NONE AUTO
C 283000000 5900000 NONE AUTO
C 289500000 6875000 NONE AUTO
C 306000000 6900000 NONE AUTO
C 313000000 6875000 NONE AUTO
C 314000000 6900000 NONE AUTO
C 330000000 6875000 NONE AUTO
C 346000000 6875000 NONE AUTO
C 354000000 6900000 NONE AUTO
C 354000000 6950000 NONE AUTO
C 372000000 6875000 NONE AUTO
C 377750000 6900000 NONE AUTO
C 386000000 6875000 NONE AUTO
C 386000000 6900000 NONE AUTO
C 394000000 6900000 NONE AUTO
C 410000000 6900000 NONE AUTO
C 418000000 6900000 NONE AUTO
C 434000000 6900000 NONE AUTO
C 442000000 6900000 NONE AUTO
C 450000000 6875000 NONE AUTO
C 490000000 6875000 NONE AUTO
C 514000000 6900000 NONE AUTO
C 530000000 6900000 NONE AUTO
C 634000000 6900000 NONE AUTO
C 714000000 6875000 NONE AUTO
# freq pol sr fec
# Astra 19.2E
S 12551500 V 22000000 5/6
# Eurobird 9E
S 11843000 V 27500000 AUTO
# Hotbird 13E
S 11727000 V 27500000 AUTO
# Astra 23.5E
S 12565000 V 27500000 AUTO
# Eurobird 28.5E
S 11623000 H 27500000 2/3
# Eutelsat 16.0E & Telecom2 8.0W & Amos 4.0W
S 10972000 V 27500000 AUTP
# Sirius 5.0E
S 11727000 H 27500000 5/6
# Turksat 42.0E
S 10970000 V 30000000 5/6
# Atlantic Bird 1 12.5W
S 11408000 V 27500000 3/4
# Atlantic Bird 3 5.0W
S 11591000 V 20000000 2/3
# Hispasat 30.0W
S 12015000 V 27500000 3/4
# Nilesat 101/102 & Atlantic Bird 7.0W
S 10719000 V 27500000 3/4
# Telsat 12 15.0W
S 11060000 H 19279000 3/4
# Thor 1.0W
S 11216000 V 24500000 7/8
# Express AM1 40.0E
S 10967000 V 20000000 AUTO
# Hellas Sat 39.0E
S 12565000 V 30000000 AUTO
# Eutelsat W3A 7.0E
S 11283000 V 27500000 AUTO
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment