Using System LEDs for Recording Status

Version 3 (brfransen, 03/25/2010 04:19 pm)

1 3 brfransen
h1. Using System LEDs for Recording Status 
2 1
3 3 brfransen
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.
4 3 brfransen
Follow the instructions below for installation on your LinHES system or see the original article on the "MythTV Wiki.":http://www.mythtv.org/wiki/Using_System_LEDs_for_Recording_Status
5 3 brfransen
 
6 3 brfransen
h2. Hardware
7 1
8 3 brfransen
You will need:
9 3 brfransen
* A female DB9 serial connector, preferably with wires connected to the pins
10 3 brfransen
* Some extra wire 
11 1
12 2 brfransen
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.
13 2 brfransen
14 1
Next, focusing on the female DB9. If you face the connector toward you there are 9 holes, the pinout is:
15 1
<pre>
16 3 brfransen
5 4 3 2 1
17 3 brfransen
 9 8 7 6
18 1
</pre>
19 1
The pins we want to work with are 4 (DTR), 5 (Ground), and 7 (RTS).
20 1
21 1
You will now use your extra wire to connect 5 (Ground) to the two white cables coming from the case LEDs.
22 1
23 1
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.
24 1
25 1
Finally, connect 7 (RTS) to the other colored cable. Again, maybe a resistor.
26 1
27 1
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.
28 1
29 3 brfransen
> _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._
30 1
31 3 brfransen
Plug the DB9 into a serial port and note which port number it is.
32 1
33 3 brfransen
h2. Software
34 1
35 3 brfransen
Now for the Python script to monitor if the encoders are recording.
36 1
37 3 brfransen
To install on LinHES:
38 3 brfransen
<pre>
39 3 brfransen
sudo pacman -Sy recstat
40 3 brfransen
</pre>
41 1
42 3 brfransen
Edit @/usr/bin/recstat.py@ for your system:
43 3 brfransen
* Modify encoder lines to match the name and number of encoders listed on the MythWeb Status page.
44 3 brfransen
* 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)@)
45 3 brfransen
* OPTIONAL: Change the @time.sleep(1)@ line to change how often the status of the encoders is checked
46 1
47 3 brfransen
To start the recstat program at boot run @sudo add_service.sh recstat@