[mythtv-users] New Firewire Channel Change Script w/ Stabilization!

Steven Adeff adeffs.mythtv at gmail.com
Thu Oct 4 16:54:03 UTC 2007


I'd been running the keep_dct_alive script for a while and was still
missing some recordings. This was due to the fact that the script has
to be run at intervals (I had it run at the 58, 13, 28 and 43 minute
marks using cron).

So this led me to write the following script, which will take the GUID
of the box as part of the parameter to be passed when setting it up to
be used in mythtv-setup to change the channel of that box and then run
firewire_tester to "stabilize" the connection.

In testing I ran into a few issues with proper stabilization. To work
around these I've implemented the following...
-run firewire_tester such that it receives two "stabilized" messages
before exiting the script.
-pause after the channel change before running firewire_tester
-after xx attempts at stabilization send the change channel command
again and re-try the stabilization routine.

So far it's worked excellently for me so I'm releasing it into the
wild for others to test. This should negate the need for
keep_dct_alive. I currently have it setup to use 6200ch, if you need
another channel changer command you'll have to modify the script to
meed its needs.

If you see a better method for implementing something I've done please
reply with it, I'm very open to improving the script.

Without further ado...
--------------- 6200changer.sh ---------------
#!/bin/bash
#

GUID=`echo "$1"|sed -r "s/[A-Z]+/\L&/g"`
CHANNEL=$2

NODE=`plugreport | grep $GUID | awk '{if (($1 == "Node")  && ($4 == "'"0x$GUID"'
")) print $2}'`
echo "Node: '$NODE'"
echo "Changing to channel $CHANNEL"
6200ch -v -s -g $GUID $CHANNEL
#maybe a pause is needed?
sleep 4

STABILIZE="1"
COUNT=0
TOTALCOUNT=0
STABLECOUNT=0
echo "Stabilizing Firewire Connection!..."
#maybe an initial run followed by a verification run?

#initial run
firewire_tester -B -r2 -n$NODE

#while [ "$STABILIZE" != "Broadcast Fix: Success (already stable)" ]
while [ $STABLECOUNT -lt 2 ]
do
        STABILIZE=`firewire_tester -B -n$NODE|grep "already stable"`
        if [[ "$STABILIZE" != "Broadcast Fix: Success (already stable)" ]]
        then
                echo "Not Stable! Attempt $COUNT"
                ((COUNT+=1))
                ((TOTALCOUNT+=1))
                if [ $TOTALCOUNT -gt 50 ]
                then
                        echo "FAILED to Stabilize!!"
                        exit 1
                fi
                if [ $COUNT -gt 10 ]
                then
                        6200ch -v -s -g $GUID $CHANNEL
                        COUNT=0
                        firewire_tester -B -r2 -n$NODE
                fi
        else
                echo $STABILIZE
                ((STABLECOUNT+=1))
        fi
done
echo "Stable!"
exit 0


-- 
Steve


More information about the mythtv-users mailing list