[mythtv-users] How to ensure STB is on

Phil Linttell phil.linttell at rogers.com
Mon May 3 18:58:16 UTC 2010


> Date: Sun, 2 May 2010 22:41:06 -0400
> From: Jerry Rubinow <jerrymr at gmail.com>
> Subject: [mythtv-users] How to ensure STB is on
> To: Discussion about mythtv <mythtv-users at mythtv.org>
>
> After a few trouble-free years, for the third time in a month, I discovered
> my STB had somehow entered a power-off state, and as a result I missed a
> couple of recordings.

Hi Jerry,

I gather you only care about turning the STB on, not off?  I'm using the
external channel changer 10f "mythchanger" by majoridiot that has a
power on function - not a toggle, it only turns the STB on.  I'm using
the sa4250, but the program supports the 3250 as well.

https://wiki.ubuntu.com/majoridiot

Note, that the power on function adds considerable time to a channel
change.  I call it from /etc/rc.local at system startup (in case of a
power failure):
    mythchanger -f 3 -P -c 513

Also, I have a wrapper script I use that tests for a failed channel
change, and tries turning on the STB after a failure.   In addition, I
occasionally had (have?) firewire failures, and if the channel change
still fails after a power on, I try reloading the firewire drivers.  It
also adds seconds after a channel change to allow the HD-PVR to
"lock-on" to the new signal.   The script is written with the goal of
minimizing the channel change time in each on of the cases, and so exits
as soon as it gets success.



#! /bin/sh

# Author: Phil Linttell <phil.linttell at rogers.com>
#
# Please remove the "Author" lines above and replace them
# with your own name if you copy and modify this script.

DESC="mythchanger reload wrapper"
MYTHCHANGER_NAME="mythchanger"
MYTHCHANGER_DIR="/usr/bin"
MYTHCHANGER_ARGS="-f 3"
# six second delay to allow HD-PVR to adjust to channel change and grab
the correct resolution
DELAY=6
MODULES="dv1394 ohci1394 raw1394 ieee1394"

channel_change ()
{
    SUCCESS=false
#   echo "$MYTHCHANGER_NAME: changing channel $* $MYTHCHANGER_ARGS"
    $MYTHCHANGER_DIR/$MYTHCHANGER_NAME $* $MYTHCHANGER_ARGS
    case "$?" in
        0)  return 0 ;;
        1)
#           echo "mythchanger: failed"
            return 1
        ;;
        *)
            return 1
#           echo "unknown return code"
        ;;
    esac
}

reload_firewire ()
{
    local MODULES_MISSING=false

#   echo "Removing firewire modules"
    modprobe -r $MODULES

#   echo "Re-loading firewire modules"
    for mod in $MODULES
    do
#       echo "loading $mod"
#       modprobe $mod 2> /dev/null || MODULES_MISSING=true
        modprobe $mod
    done

    if $MODULES_MISSING; then
#       echo "Unable to load firewire modules."
        exit 1
    fi

    sleep 2
}

test -f $MYTHCHANGER_DIR/$MYTHCHANGER_NAME || exit 0

MYTHCHANGER_ARGS="$MYTHCHANGER_ARGS $*"
# echo "$MYTHCHANGER_NAME: args $MYTHCHANGER_ARGS"

# add logging and modload behaviour from lirc
# change to for loop with graceful exit

# change channel
channel_change
if [ "$?" = "0" ]; then
    sleep $DELAY
    exit 0
fi

# echo "Trying to power on STB..."
channel_change -P
if [ "$?" = "0" ]; then
#   echo "Channel change succeeded"
    sleep $DELAY
    exit 0
fi

# try re-loading firewire modules
reload_firewire
channel_change
if [ "$?" = "0" ]; then
#   echo "Channel change succeeded"
    sleep $DELAY
    exit 0
fi

# echo "Channel change failed again"
# echo "Aborting"
exit 1




More information about the mythtv-users mailing list