[mythtv-users] Tuning QAM for Charter Cable with HD3000

jborn at charter.net jborn at charter.net
Sat Mar 18 19:43:17 UTC 2006


I believe that I should be used QAM256 based on this thread here:http://www.gossamer-threads.com/lists/mythtv/users/188987?search_string=charter%20cable;#188987
The last messager in the thread is using Charter Cable and is on the same loop as I am on.

When I tried to send an attachment it was quarantined, so I will include in body this time.  I modified the script to use all the frequency files that use QAM256.  The end result is:
#/bin/bash

#
# Very very simple way of creating a channels.conf file that contains only
# non-encrypted channels coming in over cable.  The first lines of this file 
# (lines 23, 26, 29, and 32) need to be adjusted to run on each computer.  You 
# will also need a ~/.azap folder.  This script must be run directly from the 
# computer that contains the tuner.  If you ssh into the computer and try to 
# run this script, the mplayer timings will be off and it will probably not 
# function correctly.  This script takes a while to run and should be run 
# while the computer is not being used.  This script will probably not function
# if it finds more that 999 total channels (encrypted and non-encrypted) or 
# more than 99 non-encrypted channels.  These limitations can be easily
# fixed by someone who knows what they are doing.  The end of the script 
# contains a section to automatically update the mysql database.  What's 
# written seems to work for me however I don't know if it will work elsewhere 
# so uncomment at your own risk.
#
# Script by Dylan R. Semler
#

#Path to the atsc frequency files
pathToFrequencyFiles=/usr/local/share/dvb/scan/atsc

#path to the atsccan utilility
pathToScanExc=/usr/local/bin

#Path to the dvb-apps azap subdirectory
pathToAzapExc=/usr/local/bin

#Path to store temp files
tempDir=/var/video/livetv

#Path to DVB device:
dvbDevice=/dev/dvb/adapter0/dvr0

#Backup current channels.conf file
mv ~/.azap/channels.conf ~/.azap/channels.conf.back >& /dev/null
mv ~/.azap/uniqueSortedChannels.conf ~/.azap/uniqueSortedChannels.conf.back >& /dev/null

echo $pathToFrequencyFiles
frequencyFiles=`ls $pathToFrequencyFiles/*QAM256*`
for frequencyFile in $frequencyFiles
do
  echo Using atscscan to search for posible channels using the following frequency file: $frequencyFile

  #run atscscan to generate channels.conf file in ~/.azap/
  $pathToScanExc/atscscan $frequencyFile >> ~/.azap/channels.conf 2>/dev/null

done

sort -u ~/.azap/channels.conf > ~/.azap/uniqueSortedChannels.conf

#Replace the ugly-looking first entries of uniqueSortedChannels.conf with try###
for (( i = 999 ; i >= 1 ; i-- )); do 
  sed -i "$[i]s/^.*\]/try$i/" ~/.azap/uniqueSortedChannels.conf
done

#Get number of lines in uniqueSortedChannels.conf
total=`cat -n ~/.azap/uniqueSortedChannels.conf | awk '{ print $1 }' | tail -1`

channum=0

#Test channels for video footage:
for (( i = 1 ; i <= $total ; i++ ));
do

    #Try to tune channel
    $pathToAzapExc/azap -r try$i >& /dev/null &
    azapid=$!
    sleep 2

    #Create 5 second long test video
    cat $dvbDevice > $tempDir/test.mpg &
    catid=$!
    sleep 5
    kill $catid >& /dev/null
    kill $azapid >& /dev/null

    #Time how long it takes mplayer to play the video.  If it is less than
    #2.5 seconds, then the channel is assumed to be encrypted or a music
    #channel
    echo | time -o $tempDir/time.dat mplayer $tempDir/test.mpg >& /dev/null
    length=`sed -e 's/^.*system 0:0//' -e 's/elapsed.*$//' -e /outputs/d -e s/\\\.// $tempDir/time.dat`

    #Adjust uniqueSortedChannels.conf if no video was played
    if [ $[10#$length] -lt 250 ];
    then
	sed -i /try$i:/d ~/.azap/uniqueSortedChannels.conf
	length=
    else
	channum=$((channum+1))
    fi

done
if [ $channum = 1 ]; 
then
    echo "found $channum channel"
else 
    echo "found $channum channels"
fi

#Re-number uniqueSortedChannels.conf file in order
for (( i = 999 ; i >= 1 ; i-- )); 
do 
    sed -i "$[i]s/try[0-9]\{1,3\}/try$i/" ~/.azap/uniqueSortedChannels.conf
done

#Remove temp files
rm $tempDir/test.mpg
rm $tempDir/time.dat


# Auto update mythtv's mysql database--not complete, but seems to work for me.

#rm channelinput.sql

#for (( i = $channum ; i >= 1 ; i-- )); do
#    echo $i
#    serviceid=`sed -n $[i]s/^.*://p ~/.azap/uniqueSortedChannels.conf`
#    frequency=`sed -n $[i]s/try[0-9]*\://p ~/.azap/uniqueSortedChannels.conf| sed s/\:QAM.*//`
#    mplexid=`grep $frequency mplexid.dat | awk '{ print $1 }'`
#    if [ $i -lt 10 ]; then
#	j=0$i
#    else
#	j=$i
#    fi
#    echo "INSERT INTO channel VALUES ('31$j','1$j','NULL','3','try$i','try$i','none','NULL','','','0','32768','32768','32768','32768','Default','0','1','','1','$mplexid','$serviceid','1');" >> channelinput.sql
#done

#echo flush privileges\; >> channelinput.sql

#mysql -u root -p mythconverg < channelinput.sql


More information about the mythtv-users mailing list