2 ###############################################################################
4 ###############################################################################
5 # Copyright (C) 1998-2008 VideoLAN
7 # Authors: Christophe Massiot <massiot@via.ecp.fr>
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 ###############################################################################
31 if test x
"$1" != x
"-r" -o -z "$2"; then
32 echo "Usage: $0 -r <remote socket> [<slot 0-n>]" >&2
39 if which dvblastctl
>/dev
/null
; then
40 DVBLASTCTL
="dvblastctl -r $SOCKET"
41 elif test -x "$PWD/dvblastctl"; then
42 DVBLASTCTL
="$PWD/dvblastctl -r $SOCKET"
43 elif test -x "$BASE_DIR/dvblastctl"; then
44 DVBLASTCTL
="$BASE_DIR/dvblastctl -r $SOCKET"
46 echo "Couldn't find dvblastctl"
52 # Check adapter status
55 $DVBLASTCTL mmi_status
>/dev
/null
58 if test $NUM_SLOTS -eq 255; then
59 echo "Unable to set up a connection" >&2
62 if test $NUM_SLOTS -eq 0; then
63 echo "Adapter has no available CAM module" >&2
66 if test -z $SLOT; then
67 echo "Defaulting to slot #0"
70 if test "$SLOT" -ge $NUM_SLOTS; then
71 echo "Slot out of range, pick in the range 0-`expr $NUM_SLOTS - 1`" >&2
80 $DVBLASTCTL mmi_slot_status
$SLOT >/dev
/null
83 if test $STATUS -ne 0; then
84 echo "Slot is not ready, retry later" >&2
88 $DVBLASTCTL mmi_get
$SLOT >/dev
/null
91 if test $STATUS -eq 255; then
92 echo "Opening MMI session..."
93 $DVBLASTCTL mmi_open
$SLOT
95 if test $STATUS -eq 255; then
96 echo "Communication error" >&2
98 elif test $STATUS -ne 0; then
99 echo "Couldn't open MMI session" >&2
111 $DVBLASTCTL mmi_get
$SLOT
116 echo "Connection closed" >&2
120 echo -n "Your choice (empty for extra choices) ? "
123 echo "CAUTION: the password won't be bulleted, be alone"
124 echo -n "Your choice (empty for extra choices) ? "
131 echo -n "Your choice: (B)ack, (C)lose or (R)etry ? "
134 echo -n "Your choice: [0-$STATUS], (C)lose or (R)etry ? "
142 if test -z "$ANSWER"; then
143 echo -n "(B)ack, (C)lose or (R)etry ? "
148 if ! $DVBLASTCTL mmi_send_text
$SLOT; then
149 echo "mmi_send_text failed, apparently" >&2
154 C|c|Close|close|CLOSE
)
155 $DVBLASTCTL mmi_close
$SLOT
158 R|r|Retry|retry|RETRY
)
162 echo "Invalid string, retry..."
167 if ! $DVBLASTCTL mmi_send_text
$SLOT "$ANSWER"; then
168 echo "mmi_send_text failed, apparently" >&2
178 if ! $DVBLASTCTL mmi_send_choice
$SLOT 0; then
179 echo "mmi_send_choice failed, apparently" >&2
184 C|c|Close|close|CLOSE
)
185 $DVBLASTCTL mmi_close
$SLOT
188 R|r|Retry|retry|RETRY
)
192 echo "$ANSWER" |
grep -q "^[[:digit:]]\+\$"
193 if test $?
-ne 0; then
194 echo "Invalid string, retry..."
196 if ! $DVBLASTCTL mmi_send_choice
$SLOT "$ANSWER"; then
197 echo "mmi_send_choice failed, apparently" >&2