* demux.c: Fix continuity counter errors for outgoing EITs. Also fix generation of...
[dvblast.git] / dvblast_mmi.sh
blob51ab38bf6226514160ba721b2c08bdf5701205a0
1 #!/bin/sh
2 ###############################################################################
3 # dvblast_mmi.sh
4 ###############################################################################
5 # Copyright (C) 1998-2008 VideoLAN
6 # $Id$
8 # Authors: Christophe Massiot <massiot@via.ecp.fr>
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 ###############################################################################
25 BASE_DIR=`dirname $_`
29 # Check args
32 if test x"$1" != x"-r" -o -z "$2"; then
33 echo "Usage: $0 -r <remote socket> [<slot 0-n>]" >&2
34 exit 1
37 SOCKET=$2
38 SLOT=$3
40 if which dvblastctl >/dev/null; then
41 DVBLASTCTL="dvblastctl -r $SOCKET"
42 elif test -x "$PWD/dvblastctl"; then
43 DVBLASTCTL="$PWD/dvblastctl -r $SOCKET"
44 elif test -x "$BASE_DIR/dvblastctl"; then
45 DVBLASTCTL="$BASE_DIR/dvblastctl -r $SOCKET"
46 else
47 echo "Couldn't find dvblastctl"
48 exit 1
53 # Check adapter status
56 $DVBLASTCTL mmi_status >/dev/null
57 NUM_SLOTS=$?
59 if test $NUM_SLOTS -eq 255; then
60 echo "Unable to set up a connection" >&2
61 exit 2
63 if test $NUM_SLOTS -eq 0; then
64 echo "Adapter has no available CAM module" >&2
65 exit 3
67 if test -z $SLOT; then
68 echo "Defaulting to slot #0"
69 SLOT=0
71 if test "$SLOT" -ge $NUM_SLOTS; then
72 echo "Slot out of range, pick in the range 0-`expr $NUM_SLOTS - 1`" >&2
73 exit 3
78 # Check CAM status
81 $DVBLASTCTL mmi_slot_status $SLOT >/dev/null
82 STATUS=$?
84 if test $STATUS -ne 0; then
85 echo "Slot is not ready, retry later" >&2
86 exit 3
89 $DVBLASTCTL mmi_get $SLOT >/dev/null
90 STATUS=$?
92 if test $STATUS -eq 255; then
93 echo "Opening MMI session..."
94 $DVBLASTCTL mmi_open $SLOT
95 STATUS=$?
96 if test $STATUS -eq 255; then
97 echo "Communication error" >&2
98 exit 2
99 elif test $STATUS -ne 0; then
100 echo "Couldn't open MMI session" >&2
101 exit 4
103 sleep 3
108 # Da loop
111 while :; do
112 $DVBLASTCTL mmi_get $SLOT
113 STATUS=$?
115 case $STATUS in
116 255)
117 echo "Connection closed" >&2
118 exit 2
120 254)
121 echo -n "Your choice (empty for extra choices) ? "
123 253)
124 echo "CAUTION: the password won't be bulleted, be alone"
125 echo -n "Your choice (empty for extra choices) ? "
127 252)
128 sleep 1
129 continue
132 echo -n "Your choice: (B)ack, (C)lose or (R)etry ? "
135 echo -n "Your choice: [0-$STATUS], (C)lose or (R)etry ? "
137 esac
139 read -r ANSWER
141 case $STATUS in
142 254|253)
143 if test -z "$ANSWER"; then
144 echo -n "(B)ack, (C)lose or (R)etry ? "
145 read -r ANSWER
147 case "$ANSWER" in
148 B|b|Back|back|BACK)
149 if ! $DVBLASTCTL mmi_send_text $SLOT; then
150 echo "mmi_send_text failed, apparently" >&2
151 else
152 sleep 1
155 C|c|Close|close|CLOSE)
156 $DVBLASTCTL mmi_close $SLOT
157 exit 0
159 R|r|Retry|retry|RETRY)
163 echo "Invalid string, retry..."
165 esac
167 else
168 if ! $DVBLASTCTL mmi_send_text $SLOT "$ANSWER"; then
169 echo "mmi_send_text failed, apparently" >&2
170 else
171 sleep 1
177 case "$ANSWER" in
178 B|b|Back|back|BACK)
179 if ! $DVBLASTCTL mmi_send_choice $SLOT 0; then
180 echo "mmi_send_choice failed, apparently" >&2
181 else
182 sleep 1
185 C|c|Close|close|CLOSE)
186 $DVBLASTCTL mmi_close $SLOT
187 exit 0
189 R|r|Retry|retry|RETRY)
193 echo "$ANSWER" | grep -q "^[[:digit:]]\+\$"
194 if test $? -ne 0; then
195 echo "Invalid string, retry..."
196 else
197 if ! $DVBLASTCTL mmi_send_choice $SLOT "$ANSWER"; then
198 echo "mmi_send_choice failed, apparently" >&2
199 else
200 sleep 1
204 esac
206 esac
208 echo
209 done