Doug's Compendium of Stuff


Stuff

Main
Where Is Doug?
My Bookmarks
My Resume
Pacbell Outages
Pilot Logbook

Code

Tournament
Jar Search
DCT6200 Firewire Tuner (For Motorola DCT6200 set top box and Freevo)
Serial Port Tuner (For Motorola DCT2XXX set top box and Freevo)
Gentoo IVTV Ebuild
Java Internet Jukebox

Old

2008: 08 07 03 02
2007: 12 08 07
2006: 12 06 02
2005: 11 10 07 06 05 04
2004: 07 06
2003: 10 08 07 05 04

Offsite

My Wife
My Work

Contact

Email:



The Few, The Proud, The Pradipta 416


Serial Port Tuner -- November 2004

I recently got Freevo (http://freevo.sourceforge.net/) working at my house. I have digital cable from Comcast in Harbor City, CA. My set top box is a Motorola DCT2224. I have split the signal coming out of the set top box and run it to my television (for normal tv watching) and to my Freevo box (for recording). This set up makes it impossible to record a show while watching another, but for my purposes that is ok.

Another problem with this set up is you can't use Freevo to natively change the channel on the TV tuner card -- it must always be tuned to channel 3 like the TV to receive the signal coming from the set top box. You can get away with just leaving the set top box tuned to the channel you want to record if all you are recording is one show. But the draw of these PVR's (Personal Video Recorder) is to be able to set up a whole schedule of recordings (to record shows that are on while you are at work or sleeping, for example), or to record shows while you are on vacation. To make this work, you need to make Freevo change the channel on the set top box.

There are a couple of ways to do this:

I quickly ruled out the IR transmitter option. It seemed a big pain in the ass having to install and configure yet another piece of hardware on this box. It runs linux and getting odd hardware configured and working can be an adventure at times. I already had spent enough time just getting the tv capture card, input remote control, sound, video, etc, etc, etc working on my box, a mini-itx system using the EPIA M10000 motherboard. It has a lot of nice features, but this hardware is kind of on the far end of the distribution curve of hardware running linux out there.

So this left the serial port. There are a billion references to the Motorola DCT2224 on the web (Google it). Apparently, the biggest issue is that the serial port on your set top box may not be turned on. Check this page for some ways to determine if it is on or not: Tivo Customer Support for DCT2000 Series Set Top Boxes.

During my investigations for solutions using the serial port, I ran across a bunch of software written in various languages:

Of these three options, the best by far is the implementation in the MythTV distribution. It appears to be a full implementation of the DCT2XXX protocol with all sequencing and handshakes in it. The other sources are more brute force and therefore somewhat more simple.

Because Freevo is written in python, it seemed logical to make my first step to port the MythTV C code to python -- the result is this page. (I'd like to give a tip of the hat to Chris Giffiths, the original author of the code, and Ian Forde, who hacked it slightly for use in MythTV, without whose work this port would not have been possible). You can download this archive: serialtuner.tar.gz and extract it into your local python installation's site-packages directory. It requires that the pySerial package be installed in your system. For Debian, all you need to do is

#apt-get install pyserial.

For other ways to install pySerial, check out the home page of the pySerial project at SourceForge.

To use the serialtuner python module, make sure the box you are running on is hooked up to your set top box using a standard RS232 serial cable. Then try something like the following:

python
Python 2.3.4 (#2, Sep 24 2004, 08:39:09)
[GCC 3.3.4 (Debian 1:3.3.4-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import serialtuner.dct2224tuner
>>> s = serialtuner.dct2224tuner.DCT2224Tuner()
>>> s.setChannel('301')
Serial tuner changing channel to channel [ 301 ]

If the serial port of your set top box is on, the channel should get changed!

I was lucky ... my serial port was just on, I didn't have to do anything. Others are not so lucky and you might have to call your cable company and beg them to turn it on for you. If this is the case, I wish you luck.

11/24/04: After getting this working, I called my cable company to cancel a package of channels we had ordered previously. After the package was deactivated, the serial port on my set top box stopped working! If I would set up a program to listen to the serial port when I turned on the set top box, I would get an ack packet and then nothing else. It would respond to nothing I sent it. I was discouraged until I remembered that I had read in a forum somewhere that this can happen after a service change and if you sit tight, the serial port sometimes just comes back on. This is what happened to me. After about a week, the serial port started responding to commands again. Lucky me.

Integration With Freevo

Integrating the Serial Port Tuner with Freevo was relatively simple, once I delved into the Freevo source. Let me preface all of this by saying that I am using Freevo version 1.5.2. If you are using some other version YMMV.

The first thing you need to figure out is where your Freevo source code is. This will vary by system, I imagine, but for my install of Debian, the Freevo sources get installed in /usr/lib/python2.3/site-packages/freevo. Again, if you installed from source or are using another distro, you are on your own. I will refer to this directory henceforth as $FREEVO_SOURCE.

Save this file, dct2224serial.py into $FREEVO_SOURCE/tv/plugins. Then, add the following lines to your Freevo installation's local_conf.py file:

plugin_external_tuner = plugin.activate("tv.dct2224serial")

That's it. As long as you configured Freevo's VIDEO_GROUPS to use the "external" tuner_type, the above plugin will get activated for switching channels. A couple of caveats though: This plugin works for recording and for selecting a show to watch from the program guide. When recording, the Freevo recordserver will change the channel on the set top box before starting to record. Also, when selecting a show to watch from the program guide, Freevo switches the set top box to the correct channel. While watching TV, however, channel changing does not seem to work. I haven't yet fully debugged this problem. All I know is that while watching TV and using the remote to try to flip channels, my channel changing software gets a lot of garbage input from Freevo. I don't know if this is a Freevo bug or what, further information as I figure it out. Since I don't use Freevo to watch TV anyway, this problem does not affect me so much, so the likelihood of me fixing the problem is pretty low at this point.

I know this code works for the Motorola DCT2224 set top box, but it should work for any DCT2XXX model. Also, the serial tuner module is set up to be somewhat generic, so if you have some other set top box, as long as it has a serial port and you know the communication protocol, you should be able to write a subclass of serialtuner.SerialTuner to handle changing the channels.

Maybe some soul could write a more generic plugin for Freevo to make integrating new subclasses of serialtuner.SerialTuner easier. I'm afraid my python skillz just aren't up to snuff ...

Well, I hope this might be of use to somebody out there ...

Locations of visitors to this page