Controlling DirecTV Set Top Box (STB) via USB or Serial

From MythTV Official Wiki
Revision as of 02:59, 19 January 2008 by Wesmoc (talk | contribs) (Moved the usb->serial cable options to a heading of their own)

Jump to: navigation, search


DirecTV supplies and has supplied a variety of set top boxes (referred to as "STB" from here on) to consumers. Nearly all of them have the ability, although not directly advertised, to be controlled from an external device, such as a MythTV BackEnd.

The D10 & RCA Satellite STB

Many of the older (pre 2007) STB's that were sold or leased by DirecTV have a small phone-style port on the back of the unit that is labeled as "Low Speed Data Port" or simply "Low Speed Data". This port, although it can be initially be mistaken as a standard RJ-11 phone jack, is actually quite a bit smaller (in technical terms, it is called an RJ-22) and is sometimes referred to as a "mini RJ-11" port. If you take a look at the coil handset cable on your non-cordless phone (you still have one of those, right?), you will see that the plug on that cord is the same as the port on the back of the STB.

You will need the following components in order to create a connection from your MythTV backend to the STB:

  1. a USB->Serial Adapter (USB Male to 9-pin Male) (eg:, which shows up under linux as "Prolific Technology, Inc. PL2303 Serial Port")
  2. a handset cord for a corded phone
  3. a Serial->RJ45 adapter
  4. a short length of ethernet cable with RJ-45 connectors already crimped down on each end

If you prefer to get your hands on a modular serial hood, you can omit the Serial->RJ45 adapter and the ethernet cable. I used the items listed above because that was what I had readily available.

Cable Options

WARNING: Not all USB to Serial port adapters are compatible with linux. There are a few well known ones that are made with compatible chipsets (the PL-2303 comes to mind), but there are many more that do not work with any flavor of linux. Please choose your cable with care.

Known good adapters are:

  1. The Sabrent USB->Serial port adapter (

The DirecTV D11/H20 Satellite STB

The DirecTV D11/H20 Satellite set top box contains a USB port that can be used as a serial port to change channels and perform other tasks on the box. To do this, you need the following cables:

  1. USB->Serial Adapter (usb male to 9 male).
    • IOGEAR GUC232A, ATEN UC-232A (pl2303), BAFO BF-810, QVS UR-2000M2, Sabrent SBT-USC1M and other PL2303 based adapters are known working. Succesfully tested with:
    2. July 06, 2007 Update: It has been reported that EMTC ( is no longer shipping linux compatible (PL2303) cables. Previously, they were a good and inexpensive supplier, but the replacement cables are not compatible. DO NOT BUY THESE
    3. GWC UC320 ( This works with both my HD20-100 and D11-500 boxes as of November, 2007.
    4. Other cables/adapters are unknown (use at your own risk).
  2. 9-pin Null-Modem Adapter (9 female to 9 female)
  3. 9 pin serial cable. (9 female to 9 male)

The end result of this is a null modem serial connection between computers. I assume that using two USB->Serial adapters would also work, (see note below) given that the Null Modem adapter was still used.

I used the BAFO BF-810 adapter (found for $9 online) and a pair of 9pin DSub to RJ45 adapters wired as a crossover serial cable, along with a straight-through ethernet cable.

I started with the script used to control the D10 box. I had to change the speed to 115200 from 9600 (contrary to the installers guide which says 9600 or 155200, which must be a typo). I also had to enable hardware flow control in order to get reliable operation.

NOTE: I was using 115,200 baud for months with two D-11 boxes. Around the middle of January 2007 I started getting channel change failures. Switching it to 9600 baud fixed it. My theory is that DirecTV sent down a firmware upgrade to change the all the D-11 boxes to 9600.

NOTE: D11 and H20 boxes require baud rate = 115200 (May 25, 2007)

NOTE: If baud rate = 115200 does not work with the H20 box using the CablesToGo usb->serial adapters, try 9600 (Oct 22, 2007)

NOTE: For Mac OS X connecting to a D11 or H20 use ver 1.8 which supports baud rates (for Mac and Linux) >38400. A usb to serial adapter on both ends connected by a null modem cable works fine.(May 25, 2007)

Making Your Own Custom Cable (D10/RCA)

You can either buy a cable to convert from the low speed data port to a serial port from or, using the pinout either on that page or within this page (they are the same),you can make one on your own.

Overall difficulty of making your own cable is rather low. Take your time, and be prepared to test it once (or twice) before taping everything up to make sure you got it right.

Using the items listed aboce, I grabbed with the handset cable, two serial to RJ-45 adapters, and a short RJ-45 ethernet cable and I:

  • Cut the headset cable in half, giving me two pieces of the same approx. length.
  • Cut the RJ-45 cable in half giving me two pieces of the same approx. length.
  • Cut back the outer sheathing on the RJ-45 cables at the point where I cut it in half.
  • Cut back the outer sheathing on the headset cables at the point where I cut it half (this was a pain)
  • Cut back the sheathing on the individual exposed wires on the RJ-45 cables and the headset cables.
  • Plugged the RJ-45 cables in to the Serial-RJ45 adapters.
  • Using a 9-volt battery and a cheap DC tester, I mapped out what pins on the serial side of the adapter mapped to which exposed wires on the cut end of the RJ45 cable. WRITE THEM DOWN. I cannot stress this enough. Because you will be dealing with two different wires, it is easy to get confused. I have these written down at home, and, after making my third adapter, I can tell you that the entire mapping is usually custom since serial-to-RJ45 adapters are not all created equal, the handset cables are not always color coded, and you can use any variant of RJ45 cabling.
  • Using your mapping of the serial port adapter to the individual wires in the ethernet cable, write down the proper mapping of the wires from the handset cable to the individual wires of the ethernet cable.
  • Following the mapping you just created, hand twist the appropriate wires together and use electrical tape to hold it.

Because I had the DC tester (with the little light on it), I was able to do a final test of the completed connection to confirm that the wires were connected properly. Connect the serial port end to either your MythTV backend's serial port, or, if you don't have one available (most machines now-a-days don't have more than two, and many only have one), plug it in to the USB->Serial port adapter, and plug the USB->Serial port adapter in to an available USB port. Plug the other end of the cable you just made (the mini RJ-11) in to the STB.

Now, test it and make sure it changes channels. /usr/local/bin/ setup_channel 10

If it does not work, you will get something on the command line like "excessive retries to port" or some similar error. This means, more than likely, that you reversed the mapping of the pins. I say this because that is exactly what I did. I had looked at the mini RJ11 port, and the exposed wires (all of the wires on the one that I had were the same color: gray!) and asked myself "Which end is pin 1?"

Custom Channel Change Configuration

In order to configure MythTV to call the script, you must add the command with desired options to the tuner section of mythtv-setup( User Manual:Detailed configuration Backend ).

  1. Run mythtv-setup
  2. Select Input connections
  3. Choose the connection you would like to control
  4. Add the script to the External channel change command parameter

For example, I set mine to...


The help text for this parameter says, "If specified, this command will be run to change the channel for inputs which have an external tuner device such as a cable box. The first argument will be the channel number." I interpreted this to mean that the channel will be added to whatever is specified here. This would mean that parameters could be added such as [hide, retries_number n,...]. It appears that once a command is sent like "hide" it is persistent. So you could specify it in a command window at any time.

Watch out for Xwindows using the serial port by default

In some stock /etc/X11/xorg.conf files, a serial mouse may be configured by default. If this is the case, you may notice unreliable communication with your directv box. Channel changes may not function correctly, multiple timeouts, etc. can occur. You can verify that the serial port is not in use by using the lsof command. For example,

 grigio # lsof /dev/ttyS0
 X         5479   root mem    CHR    1,5      3943 /dev/ttyS0
 grigio # 

shows that X has the /dev/ttyS0 file open. We can fix this by commenting out the appropriate device section in your /etc/X11/xorg.conf file and restarting X.

Working around some missing functionality on the channel change script

In my situation, some of the features of the script did not function in the way that I liked, or simply did not function with my STB. Specifically, with my STB, the "setup_channel" function, which is defined in the documentation as "turning the unit on, changing the channel, and hiding the on screen display" really only did the first two pieces, leaving the OSD up for an obscenely long amount of time. I simply wanted the script to change the channel and hide the OSD immediately.

While the script can take the options out of order (eg: port /dev/ttyUSB0 hide setup_channel 29), it did not seem to make any difference. This limitation required me to write a small wrapper script called "/usr/local/bin/" :

if [ "X$1" = "X" ] || [ "X$2" = "X" ]; then
       echo "Usage: $0 <port> <channel number>"
/usr/local/bin/ port $1 setup_channel $2 hide

I then used "/usr/local/bin/change_channel" in the field as outlined above in the "Custom Channel Change Configuration" section. Be sure to specify the corresponding port for each of your tuners.

Mini RJ11 (RJ22 or 4P4C) Port Pinout

1 Black
2 Red
3 Green (unused)
4 Yellow

Mini RJ11 (RJ22 or 4P4C) to Serial Port mapping

When everything is built, the pinout of the resulting cable should be:

DB9 Pin 5 -> mini RJ11 Pin 1
DB9 Pin 2 -> mini RJ11 Pin 2
DB9 Pin 3 -> mini RJ11 Pin 4

Null Modem Cable Pinout

This is a standard Null-modem cable, but here is the pinout for the sake of being complete:

TD (Transmit Data) 3 -> 2 RD
RD (Receive Data) 2 -> 3 TD
RTS (Request To Send) 7 -> 8 CTS
CTS (Clear To Send) 8 -> 7 RTS
SG (Signal Ground) 5 -> 5 SG

Serial -> RJ45 (Pin to Wire) Mapping

I used a standard SUN supplied serial to RJ45 adapter and got the following mapping of the serial port pins to the individual wires on the RJ45 cable plugged in to the serial port adapter. I also used a snort length of off-the-shelf pre-made RJ-45 (Cat5) wire.

Serial Port RJ45 (standard coloring)
1 (none) --
2 Orange/White
3 Green
4 Brown/White
5 Orange and Green/White
6 Blue
7 Brown
8 (none) --
9 (none) --

Hardware Compatibility

  • DirecTV D11-500: Channel changing works (by key). On/Off, OSD On/Off, Remote Input On/Off all work. Other features not working yet.
  • DirecTV D11-300: Channel changing not yet confirmed, some problems reported
  • DirecTV D11-100: Same results as D11-500.
  • DirecTV D12: Same as D11-100. Except the D12 supports get_channel where the D11 does not.
  • DirecTV H20: Same results as D11-500
  • DirecTV D10
  • DirecTV D12-300: Works.
  • Most DirecTV RCA STB's

Controlling D11 from Windows

I know this isn't myth-related at all, but here is how to control the D11 from windows!

  1. Install Perl (I recommend [ActivePerl])
  2. Start Perl Package Manager (PPM)
  3. Add the BdP Repository: repository add BdP
  4. Install Win32::SerialPort: install Win32-SerialPort
  5. Install Win32::API: install Win32-API
  6. Install Time::HiRes: install Time-HiRes
  7. Download the Windows version of the DirecTV Serial Control Script (see links below). Save it to C:\perl\
  • Example Execution:

perl.exe c:\perl\ port com1 baudrate 115200 flow none box_type D11 25

External Links

  • PortMon Windows software to monitor traffic on a com port
  • Com Port Toolkit Windows software to send specific commands to the serial port.

For More Information