Bob's Notepad

Notes on projects I have done and things I have learned saved for my reference and for the world to share

Wednesday, November 07, 2007

PVR150 with Set Top Box (KnoppMyth)

Last year I wrote a HOWTO that I put on the KnoppMyth Wiki. While I don't use KnoppMyth any longer and I feel that MythBuntu is a much easier solution I found myself needing information from that how-to and I apparently forget what I had named my document. After finding it I figured that I would post it here so I could find it if I needed to refer to it in the future. I included the updates that others had made as well.



Setting up KnoppMyth with one or more Hauppauge PVR-150 Cards using Dish Network or other Set Top Box

First, thanks to Mark who pointed me in the right direction at his site: http://www.blushingpenguin.com/mark/blog/?p=24

Reference System: KnoppMyth R5C7 with 2 Dish Network (Echostar) set top boxes running on two seperate Hauppauge PVR-150 PCI Cards (*NOT* the MCE version which does not have the IR Blaster)

Setting up KnoppMyth to use a set top box with the Hauppauge PVR-150's IR Blaster is actually pretty simple but there seems to be a lack of directions on exactly what needs to be done. Hopefully this will shed some light.

First of all, KnoppMyth already has lircd installed and running and should have already installed the drivers for the IR Blaster on the PVR-150. You can confirm this by checking for /dev/lircd. You should also see /dev/lirc and if you have a second PVR-150, you should see /dev/lirc1 (but you wont see an lircd1 at this time - we'll fix that later).
Step One

Make sure the lirc_pvr150 module is loading (needed for R5F27).

In some KnoppMyth distributions (like R5F27), lirc_i2c is loaded instead of lirc_pvr150. lirc_pvr150 is needed for the IR Blaster to work. To use lirc_pvr150, change following line in /etc/lirc/hardware.conf from:
MODULES="lirc_dev lirc_i2c"

to
MODULES="lirc_dev lirc_pvr150"

and reboot.
Step Two

Grab the latest firmware file. You can find a copy over at Mark's blog: http://www.blushingpenguin.com/mark/lmilk/haup-ir-blaster.bin

Note that this loads the firmware into RAM so it will increase your RAM usage. The alternative would be throwing the card in a windows machine and flashing it using Hauppauge's utilities.

Place that file in /usr/lib/hotplug/firmware on your KnoppMyth system and reboot. This step may be able to be skipped but there are some versions of the cards that have issues with IR lock ups.
Step Three

We need to find the codeset that your set top box uses. For my Dish Network / Echostar units, I used code set 1_28. If you need to find your code set, check out the blog listed at the top of this wiki and look at step #9 (you may need to look at step #6 to get an lircd.conf file as well). He has a script that you can download and use to find the code set for your set top box. If you have Dish Network tuner(s), then here is what you need in your lircd.conf file:
--- Begin file insert ---

begin remote

name blaster
bits 32
flags RAW_CODES
eps 0
aeps 0
plead 0
gap 333333
repeat_bit 0

begin raw_codes
name 0
2149318656
name 1
2149318657
name 2
2149318658
name 3
2149318659
name 4
2149318660
name 5
2149318661
name 6
2149318662
name 7
2149318663
name 8
2149318664
name 9
2149318665
name POWER
2149318666
name CH_UP
2149318671
name CH_DOWN
2149318672
name MUTE
2149318673
name VOL_DOWN
2149318674
name CH_PREVIOUS
2149318675
name VOL_UP
2149318676
name DISPLAY
2149318677
name EXIT
2149318680
name GUIDE
2149318683
name SELECT
2149318686
name AV
2149318697
name ENTER
2149318699
name MENU
2149318703
name MUP
2149318704
name MDOWN
2149318705
name MLEFT
2149318706
name MRIGHT
2149318707
end raw_codes

end remote

--- End File Insert ---

If you did the installation of KnoppMyth correctly and told the installer what remote you had, your remote control and IR receiver should already be up and running.
Step Four

We're actually almost done if you have only one tuner. All that is needed now is to have a script that mythtv can point to when it needs to change the channel. Again, Mark wrote a great script that works well. Paste this into a file called "change_channel" or something else that makes you happy and do "chmod +x change_channel". A good location for this script would be /usr/local/bin. Make sure your mythtv user has access to this script.
--- Begin Script ---
#!/usr/bin/perl

# make sure to set this string to
# the corresponding remote in /etc/lircd.conf
$remote_name = "blaster";

# Let's assume you don't need to press enter after you punch in a
# channel number. Change this to 1 if your cable box expects you press
# enter after each command
$needs_enter = 0;

# Change this to point to your rc executable
$rc_command = "/usr/local/bin/irsend";

# This subroutine actually sends the signal to the cable box
sub change_SIGNAL {
my($SIGNAL) = @_;
system ("$rc_command SEND_ONCE $remote_name $SIGNAL");
}

$SIGNAL=$ARGV[0];
open F, ">> /var/log/channel.log";
print F "channel changing $SIGNAL\n";
close F;
print "channel changing $SIGNAL\n";

# Checks if $SIGNAL begins with a digit
# If it detects that the string is made up of digits, then it puts
# spaces between the digits. Ex. 1234 becomes 1 2 3 4
if ( $SIGNAL =~ /^\d+$/ )
{
my $length = length($SIGNAL);
my $counter = 0;
my $temp;

while( $counter < $length )
{
$temp .= substr($SIGNAL,$counter,1) ." ";
$counter++;
}

change_SIGNAL($temp);
}
else
{
# argument we passed was not made up of digits, so it must be a
# command that does something other than channel changing on the
# cable box
change_SIGNAL($SIGNAL);
}

# Do we need to send enter
if ( $needs_enter )
{
system ("$rc_command SEND_ONCE $remote_name ENTER");
}

--- End Script ---

If your set top box needs an enter key pressed after a channel is entered, change the appropriate value to "1" in the script instead of "0" ... For Dish Network, 0 works fine.
Step Five

Test your script. Simply do a "./change_channel xxx" where xxx is a valid channel number on your set top box. With a little luck, your set top box will change channels.

If your script changes the channel without issue, you're set. Now just tell MythTV to use the script when it needs to change the channel. Run mythtv-setup and go to the Input Connections and in the appropriate tuner fill in the blank for the script to change channels. Just put "/usr/local/bin/change_channel" and MythTV will automatically append the channel number each time it is needed.
Stop here unless you have more than one tuner
Step Six

If you have more than one tuner, you'll need to create a seperate PID for the second PVR-150 card. You do NOT need a seperate configuration file. If you only have one tuner, what are you doing reading this section? :)

Creating the second PID is rather simple. This command will start another process of lircd without affecting the first.

/usr/sbin/lircd --device=/dev/lirc1 --output=/dev/lircd1 --pidfile=/var/run/lircd1.pid

This is dependant on the fact that /dev/lirc1 is already created -- If KnoppMyth was installed properly, it should have already detected your second PVR-150 and created that device. If this command worked properly, you should now see a /dev/lircd1 device.
Step Seven

Now you need to create a separate change channel script for this tuner. Just copy the change_channel script you created above to something such as change_channel_1 and do a chmod +x on it as well. Edit the file and change the $rc_command line to this:
$rc_command = "/usr/local/bin/irsend --device=/dev/lircd1";
Step Eight

Tell the second tuner to use this script when changing channels the same way we did in Step Four above
Step Nine

Now you probably want KnoppMyth to start the second instance of lircd on boot. To do that, create /etc/init.d/lirc1 and include these 2 lines:
#! /bin/sh
/usr/sbin/lircd --device=/dev/lirc1 --output=/dev/lircd1 --pidfile=/var/run/lircd1.pid

Do a chmod +x on this file and now tell the system to export it to all run levels by doing "update-rc.d lirc1 defaults".
--
Howto by bibleboy @ 3:31am EDT 07/07/06
Edited by Bigbro @ 16:50 PT 09/18/06 -Fixed the ARG statement syntax.
Wikimarkup made the bracket 0 bracket appear incorrectly.
inserted a tilde infront of first bracket. Works with R5C7!
Edited by RBucci @ 7:59 ET 10/15/07 - Added new Step 1 for R5F27.

Labels: ,

Reference Link


0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home