| David Rochberg | cd28bbb | 2010-10-25 16:25:27 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | usage () { |
| 7 | cat >&2 <<EOF |
| 8 | $0: Convenience wrapper around dbus-send specialized for calling |
| 9 | cromo interfaces. |
| 10 | |
| 11 | Usage: |
| 12 | $0: [modem id] [command] [remaining arguments] |
| 13 | |
| 14 | Examples: |
| 15 | $0 Fictitious/0 Simple.GetStatus |
| 16 | will get status from modem /org/chromium/ModemManager/Fictitious/0 |
| 17 | |
| 18 | $0 Gobi/2 Gobi.SetCarrier string:'Ficticious Carrier' |
| 19 | will set modem /org/chromium/ModemManager/Gobi/2 to use 'Fictitious Carrier' |
| 20 | EOF |
| 21 | } |
| 22 | |
| 23 | log_and_execute () { |
| 24 | echo >&2 Running "$@" |
| 25 | "$@" |
| 26 | } |
| 27 | |
| 28 | if [ -z "$1" -o -z "$2" ] ; then |
| 29 | usage |
| 30 | exit 1 |
| 31 | fi |
| 32 | |
| 33 | MODEM="$1" |
| 34 | COMMAND="$2" |
| 35 | shift 2 |
| 36 | |
| 37 | log_and_execute dbus-send --system --print-reply --fixed \ |
| 38 | --dest=org.chromium.ModemManager \ |
| 39 | /org/chromium/ModemManager/"$MODEM" \ |
| 40 | org.freedesktop.ModemManager.Modem."$COMMAND" \ |
| 41 | "$@" |