One Tuner Firewire Priming Script
Author | Sean Donovan |
Description | One-tuner firewire priming script |
Supports |
This is a script which is invoked each time a channel change is requested and a firewire connection needs to be working. It first tests the existing p2p and channel settings and if OK, test to see if the result from test-mpeg2 is a non-zero file which means the firewire connection is working. If the result is negative for any of the p2p, channel and non-zero file tests, it then tries to use plugctl to reset the firewire connection, and then runs the test-mpeg2 test again. It repeats ten times and if it gets 10 non-zero results, it fails.
Note:
- It relies on the 6200ch change channel script.
- It assumes the firewire connection is on node 1 and p2p routing (not bcast).
- If your node is not 1, be sure to add the correct node in front of the channel change command. IE: '/home/6200ch -n2 $1' rather than '/home/6200ch $1'
- If you run mythbackend with a log file, i.e. "mythbackend >> /home/mythbackend_log.log &", the echo statements below will appear in the log which is useful for debugging.
#!/bin/bash # v1.02, a Firewire change channel and test script by Sean Donovan, techonfoot.com # Released under GPL, 2006 # Revision history # v1.02 - Fixed the unnecessary kill_test.sh script # v1.01 - Added detection for conditions that work intermittently, i.e. test-mpeg2 will work # but the next capture by MythTV won't. Usually when p2p is 0 or channel <> 63. # Fixed a bug whereby the script expects the kill_test.sh script in the /home directory. # v1.00 - Genesis # # ------------------------ # Prime the variables used to exit the while loop and set error messages # C2 is used to avoid the while loop or exit it, if the firewire is primed # C3 is used to notify either an error condition (=1) or not (=0) C2=0 C3=1 # Change the channel /home/6200ch $1 # Then change into the directory with the kill_test.sh script cd /home # First check to make sure the firewire port is set up correctly or the # "Is it primed?" test could report positive but the firewire is in a failing state. T1=`plugctl -n 1 opcr[0].n_p2p_connections` T2=`plugctl -n 1 opcr[0].channel` if [ $T1 != "1" ] ; then # Oops, p2p isn't one, let it go into the while loop for reset. echo "###### Oops, p2p isn't one! Going to reset Firewire" elif [ $T2 != "63" ] ; then # Oops, the channel isn't 63 echo "###### Oops, the channel isn't 63! Going to reset Firewire" else # Now check if the firewire is primed already, then do nothing: test-mpeg2 -r 1 > testcap.ts & sleep 1 killall test-mpeg2 if [ -s testcap.ts ] ; then echo "#################" echo "# Firewire is primed!!!!!!!!!!!!" echo "################" # No error and C3=0 # Don't enter the while loop, the firewire is working already... C2=11 fi fi # While the counter is less then or equal to 10 # Enter the while loop and reset the firewire while [ $C2 -le 10 ] do C2=$((C2+=1)) echo "##### Now Changing the Firewire setup for the $C2 time " # First set p2p to 0 and do a capture which seems to reset everything plugctl -n 1 opcr[0].n_p2p_connections=0 test-mpeg2 -r 1 > testcap.ts & sleep 1 killall test-mpeg2 # Now set it to what seems to work best, at least for the DCT-6200 series tuner... plugctl -n 1 ompr.bcast_channel=0 plugctl -n 1 opcr[0].channel=63 plugctl -n 1 opcr[0].bcast_connection=0 plugctl -n 1 opcr[0].n_p2p_connections=1 test-mpeg2 -r 1 > testcap.ts & sleep 1 killall test-mpeg2 if [ -s testcap.ts ] ; then echo "################" echo "# Firewire is primed!!!!!!!!!!!!" echo "################" C3=0 # Exit the loop C2=11 fi # Otherwise repeat the loop done # Now print the error codes if any. if [ $C3 -eq 1 ] ; then echo "XXXXXXXXXXXXXXXX" echo "X Craappp it failed after ten tries - the tuner on?" echo "XXXXXXXXXXXXXXX" fi # Clean Up rm testcap.ts
What about node changes?
The above works great for me except if my node unexpectedly changes. You'll need to know in advance what the GUID of your settopbox is and I've added the following to the top of the above script to account for node changes:
GUID=your-guid-here plugreport | grep $GUID | cut -c 6 | sed 's/^[ \t]*//;s/[ \t]*$//' > /tmp/node NODE=`cat /tmp/node`
and substitute "-n $NODE" and "-r $NODE" for the "-n 1" and "-r 1". Also add "-g $GUID" to your 6200ch command as well.