Controlling DirecTV Set Top Box (STB) via USB or Serial
- 1 Overview
- 2 Cable Options
- 3 The D10 & RCA Satellite STB
- 4 The DirecTV D11/H20 Satellite STB
- 5 The DirecTV H21 Satellite STB
- 6 The DirecTV H23 Satellite STB
- 7 DirecTV H24 Satellite STB
- 8 Making Your Own Custom Cable (D10/RCA)
- 9 Custom Channel Change Configuration
- 10 Watch out for Xwindows using the serial port by default
- 11 udev rules
- 12 Working around some missing functionality on the channel change script
- 13 Mini RJ11 (RJ22 or 4P4C) Port Pinout
- 14 Mini RJ11 (RJ22 or 4P4C) to Serial Port mapping
- 15 Null Modem Cable Pinout
- 16 Serial -> RJ45 (Pin to Wire) Mapping
- 17 Hardware Compatibility
- 18 Controlling D11 from Windows
- 19 External Links
- 20 For More Information
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.
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.
WARNING: You MUST hit the red reset button for many DirecTV receivers to recognize USB-to-serial adapters. The docs that say the port is hot-swap are lying. Further, neither rebooting from the UI nor yanking the power cord is sufficient. Apparently, that red reset button does something particularly special....
Known good adapters are:
- The Sabrent USB->Serial port adapter (http://www.newegg.com/Product/Product.aspx?Item=N82E16812156008)
- WARNING: I ordered one of these and it no longer works with the DirecTV box. These are now using the pl2303X chips instead of the pl2303 and do not work.
- IOGEAR GUC232A, ATEN UC-232A (pl2303), BAFO BF-810, QVS UR-2000M2, Sabrent SBT-USC1M and other PL2303 based adapters are known working.
- WARNING: I ordered two of these (Sabrent?) and they no longer work with the DirecTV box. These are now using the pl2303X chips instead of the pl2303 and do not work.
- A new IOGear GUC232A unit worked for me on 2010-06-17, so either they still use the older rev (unlikely) or DirecTV upgraded to a newer Linux kernel that fixes the driver bug with the new revision (likely).
- July 06, 2007 Update: It has been reported that EMTC (http://www.emtcompany.com/products/adapters/dxubdb9-usb-to-serial-db9-adapter-cable.htm) 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
- GWC UC320 (http://www.newegg.com/Product/Product.asp?Item=N82E16812107108). This has been reported to work on both the HD20-100 and D11-500 boxes as of November, 2007.
- http://www.dtvcontrol.com/index.aspx?content=cable, which shows up under linux as "Prolific Technology, Inc. PL2303 Serial Port"
- Dynex DX-UBDB9 purchased off of ebay (February 2009 and August 2009) work fine on the H20-600, H20-100 and H21-200.
- Paterson Technology USB TV Translator. Works flawlessly on an H23 receiver (also works with D11, D12, and H20) and has additional logic to eliminate the channel banner quickly.
- Other cables/adapters are unknown (use at your own risk).
Be careful, a lot of these adapters are no longer pl2303 based although they carry the same Model number. Try http://www.cooldvr.com. He carries a complete set of cables (pc or mac to stb) that are tested to work. Cost about the same as buying the parts individually
Official USB to Serial Cable Support
According to the Installers Guide V2.2, the following USB to Serial Adapters are fully supported:
|Manufacturer||Model||USB Vendor ID||USB Product ID|
Therefore, it is possible (though not guaranteed) that your particular USB-Serial adapter will work if it has:
- USB Vendor ID= 0x067B
- USB Product ID= 0x2303
To find this out, use the lsusb command after plugging in your device. If it shows a line of output like the following, it should theoretically work.
$ lsusb Bus 002 Device 003: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
The USB port on most set top boxes (STBs) should support hot-plugging. However, if you are having troubles with your USB-Serial adapter, try plugging it in before the STB is booted. Particularly, the Installer's guide mentions that the HR20 and HR21 work this way. To do this, simply:
- Unplug the STB
- Plug in the serial adapter
- Plug in the STB and wait until it boots
Afterwards, make sure your device on the mythtv box is correct when you pass it to the script. For me, it was /dev/ttyUSB0.
A simple test command for using the correct device is the following:
# This should make the guide pop up on the D11 & D12 boxes. Substitute your box_type below. $ ./directv.pl port /dev/ttyUSB0 box_type D11 key guide
If you get "Error excessive retries", you probably are using the wrong serial port. Set it with the port command as in the above example.
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:
- a USB->Serial Adapter (USB Male to 9-pin Male)
- a handset cord for a corded phone
- a Serial->RJ45 adapter
- 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.
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:
- USB->Serial Adapter (usb male to 9 male).
- 9-pin Null-Modem Adapter (9 female to 9 female)
- 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 directv.pl 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 directv.pl 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)
NOTE: I have 2 D11 boxes hooked up to my motherboard that has only 1 serial port connection. One is connected as described above, the other uses the exact same scenario except with an extra USB to Serial adaptor to plug the cable into the motherboard's USB port. This was an extra USB to Serial Adaptor I had bought that didn't work when plugged into the D11 box, but works just fine on the other end. I now have two serial devices connected (ttyS0 and ttyUSB0) and am controlling two boxes without a problem.
The DirecTV H21 Satellite STB
While most of the info listed for the H20 should be applicable to the H21, here are a few specifics of usb->serial adapters which did and didn't work in addition to the configuration and directv.pl settings. This particular setup is: H21 <-> USB/serial converter <-> null modem adapter <-> mb serial port
|Micro Connectors||E07-160||Fry's||Didn't work||On 3/10/2010 I purchased one of these from Fry's and it worked with a D12-300|
|Cables Unlimited||USB-2920||Fry's||Didn't work|
Keep in mind that there is also this possible combination: H21 <-> USB/serial converter <-> null modem adapter <-> USB/serial converter <-> computer which was not tested.
The following parameters were given to the directv.pl script (v1.9): box_type H20 baud 9600 port /dev/ttyS0
The DirecTV H23 Satellite STB
This STB works as well using the H20 commands, version 1.9 of the script and the USB to USB cable set from http://www.cooldvr.com/Buy.html, but it works better for me using the direct channel change command rather than the keypress command. (probably a delay timing thing, but sometimes it would miss the keypresses. it would do this directly from the remote control as well, so it may just be my particular unit) Everything else in the H20 command list seems to work.
DirecTV H24 Satellite STB
The latest version of DirecTV's set top box is the H24. It has a USB port like the previous versions. The directv.pl script (see the External Links section below to download the script) works to change the channels using the H20 "box_type". I used a usb-serial converter with a PL2303 chip and a null modem adapter to hook it to the serial port on the motherboard.
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 http://www.dtvcontrol.com/index.aspx?content=cable 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/directv.pl 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 directv.pl script, you must add the command with desired options to the tuner section of mythtv-setup( User Manual:Detailed configuration Backend ).
- Run mythtv-setup
- Select Input connections
- Choose the connection you would like to control
- 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 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME 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.
If you are using a USB->serial adapter on the computer side of things, and are trying control multiple STBs, you will likely need to use udev rules for predictable naming of the USB->serial device. Instructions for udev can be found on the Device_Filenames_and_udev page.
An example rule might look like:
In that example, the KERNELS=="5-1:1.0" indicates which USB port the adapter is plugged into on the computer. If the USB->serial adaptor does not report any unique identification, using the USB port is the only way.
Note that some distributions come with a gpsd udev rule, which can get in the way. There is probably a more "proper" way to handle this problem, but on my system I just removed 99-gpsd.rules to fix the problem.
Working around some missing functionality on the channel change script
Note: This user may have been able to fix this problem by both: making sure his box_type was correct, and adjusting the delay sent to the script. Both options are documented in the script's help output.
In my situation, some of the features of the directv.pl 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 directv.pl script can take the options out of order (eg: directv.pl 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/change_channel.sh" :
#!/bin/sh if [ "X$1" = "X" ] || [ "X$2" = "X" ]; then echo "Usage: $0 <port> <channel number>" echo exit; fi /usr/local/bin/directv.pl 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
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:
|RTS||(Request To Send)||7||->||8||CTS|
|CTS||(Clear To Send)||8||->||7||RTS|
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)|
|5||Orange and Green/White|
- DirecTV D10
- DirecTV D11-100: Same results as D11-500.
- DirecTV D11-300: Works using 9600 baudrate (as of 6/9/09).
- 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 D12: Same as D11-100. Except the D12 supports get_channel where the D11 does not.
- DirecTV D12-100: Works.
- DirecTV D12-300: Works.
- DirecTV H20: Same results as D11-500
- 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!
- Install Perl (I recommend [ActivePerl])
- Start Perl Package Manager (PPM)
- Add the BdP Repository:
repository add BdP http://www.bribes.org/perl/ppm
- Install Win32::SerialPort:
- Install Win32::API:
- Install Time::HiRes:
- Download the Windows version of the DirecTV Serial Control Script (see links below). Save it to C:\perl\
- Example Execution:
perl.exe c:\perl\directv2.pl port com1 baudrate 115200 flow none box_type D11 25
- DirecTV D10 Users Manual
- DirecTV D11 Users Manual
- DirecTV D12 Users Manual
- General Set-top Information for Installers V2.1 (Contains serial command guides)
- General Set-top Information for Installers V2.2 (Updated with D12 Information)
- DirecTV Serial Control Script (directv.pl)
Script modified to work with D11Tried on 2007-12-19; didn't work with D11. Try above, v1.9 worked fine.
- Windows Version of directv.pl
- C source-code (Linux) for changing channel via serial port - works with D12-300
- D10/RCA Custom Cable information (including pinout)
- 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
- Controlling MythTV from a DirectTV D11 remote
- Controlling DirecTV Set Top Box via Network
- Contact the author of this article, User:JeffSimpson