Using System LEDs for Recording Status

If you don't care to have the Power LED or the HDD LED reflect system power or disc activity you can re-purpose them to show the recording status of each encoder in your MythTV box.
Follow the instructions below for installation on your LinHES system or see the original article on the MythTV Wiki.

Hardware

You will need:
  • A female DB9 serial connector, preferably with wires connected to the pins
  • Some extra wire

The first thing you have to do is connect your serial port to the LEDs. To do this, cut the little back connector from the HDD LED wires and Power LED wires which normally you would connect to your motherboard. Strip the ends of the wires. Each wire pair will be some color and white. If you want this to be reversible don't cut the black thing off, just figure out a better way to connect the wires.

Next, focusing on the female DB9. If you face the connector toward you there are 9 holes, the pinout is:

5 4 3 2 1
 9 8 7 6

The pins we want to work with are 4 (DTR), 5 (Ground), and 7 (RTS).

You will now use your extra wire to connect 5 (Ground) to the two white cables coming from the case LEDs.

Next, connect 4 (DTR) to one of the colored cables. Optionally you could use a resistor in this connection, something like a 1000 ohm resistor from what I hear. I didn't do it and it didn't seem necessary, but, this maybe a good idea. These resistors are probably really cheap at Radio Shack.

Finally, connect 7 (RTS) to the other colored cable. Again, maybe a resistor.

I would recommend soldering and/or electrical taping all of the connections. Personally I have just twisted the wires together and electirical taped them, but, do what you like.

Note: I just ran the wires from the DB9 plugged into the serial port at back of the case through one of the PCI slot openings. You may have a better way to do it, I couldn't think of one.

Plug the DB9 into a serial port and note which port number it is.

Software

Now for the Python script to monitor the encoders.

To install on LinHES:

sudo pacman -Sy recstat

Edit /usr/bin/recstat.py for your system:
  • Modify encoder lines to match the name and number of encoders listed on the MythWeb Status page.
  • Modify the s = serial.Serial(0) line to match the COM port you plugged the DB9 into (ie. COM1 would be s = serial.Serial(0), COM2 would be s = serial.Serial(1))
  • OPTIONAL: Change the time.sleep(1) line to change how often the status of the encoders is checked

To start the recstat program at boot run sudo add_service.sh recstat