<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Lazy Sys Admin &#187; MythTV</title>
	<atom:link href="http://www.thelazysysadmin.net/tag/mythtv/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thelazysysadmin.net</link>
	<description>Why do things the hard way?</description>
	<lastBuildDate>Tue, 11 Oct 2011 05:31:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>RS232 (Serial) Control of LG LCD TV via MythTV</title>
		<link>http://www.thelazysysadmin.net/2009/05/rs232-control-lg-lcd-tv-mythtv/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rs232-control-lg-lcd-tv-mythtv</link>
		<comments>http://www.thelazysysadmin.net/2009/05/rs232-control-lg-lcd-tv-mythtv/#comments</comments>
		<pubDate>Tue, 12 May 2009 02:04:29 +0000</pubDate>
		<dc:creator>Jon Smith</dc:creator>
				<category><![CDATA[MythTV]]></category>
		<category><![CDATA[lirc]]></category>
		<category><![CDATA[Remote Control]]></category>
		<category><![CDATA[RS232]]></category>

		<guid isPermaLink="false">http://www.thelazysysadmin.net/?p=140</guid>
		<description><![CDATA[This article describes using a Serial (RS232) link between an LG LCD TV and MythTV to perform basic control of the TV via your MythTV remote control. <a href="http://www.thelazysysadmin.net/2009/05/rs232-control-lg-lcd-tv-mythtv/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I got sick of having a remote control for everything, so I have started down the path of using RS232 (Serial) control where I can. Currently that is only my TV, but when the Decoder and DVD player get replaced I will be looking for models with remote control capability (I know I could use an IR blaster, but that can impede using the real remote and looks kind of ugly).</p>
<p>So I started by deciding the basic features I used on my TV all the time and how to remap them to the remote control I use for MythTV (I haven&#8217;t done every button, I figured if I need to use the remote once a month then so be it). The features required for me were:</p>
<ul>
<li>On/Off</li>
<li>Aspect Ratio</li>
<li>Input (DTV, Comp, RCA, VGA)</li>
</ul>
<p>I found the codes required to send to the TV on the LG website somewhere. If your TV supports RS232 there should be a document somewhere that describes the protocol used you will just need to find it.</p>
<p>I found the following code somewhere, it was originally used just to send and receive data via a serial port so I have modified it to send what I need to the TV and removed everything else.</p>
<p>Just drop the following in a file called <em>tvcontrol </em>in <em>/usr/local/bin</em></p>
<pre class="brush: python; title: ; notranslate">
#!/usr/bin/python

#allows you to capture the command switches
import sys

#get serial features for python
import serial

#this next line sets up the serial port to allow for communication
#and opens the serial port you may need to change
#ttyS0 to S1, S2, ect. The rest shouldn't need to change.
ser = serial.Serial('/dev/ttyS0', 9600, 8, serial.PARITY_NONE,
         serial.STOPBITS_ONE, xonxoff=0, rtscts=0, timeout=1)

#default COMMAND is bogus
COMMAND = &quot;nope&quot;
aspect169 = &quot;kc 00 02n&quot;
aspect43 = &quot;kc 00 01n&quot;
poweron = &quot;ka 00 01n&quot;
poweroff = &quot;ka 00 00n&quot;
inputdtv = &quot;kb 00 00n&quot;
inputav1 = &quot;kb 00 02n&quot;
inputcomp1 = &quot;kb 00 04n&quot;
inputpc = &quot;kb 00 06n&quot;

if sys.argv[1:] == ['--aspect169'] :
    COMMAND = aspect169

if sys.argv[1:] == ['--aspect43'] :
    COMMAND = aspect43

if sys.argv[1:] == ['--poweron'] :
    COMMAND = poweron

if sys.argv[1:] == ['--poweroff'] :
    COMMAND = poweroff

if sys.argv[1:] == ['--inputdtv'] :
    COMMAND = inputdtv

if sys.argv[1:] == ['--inputav1'] :
    COMMAND = inputav1

if sys.argv[1:] == ['--inputcomp1'] :
    COMMAND = inputcomp1

if sys.argv[1:] == ['--inputpc'] :
    COMMAND = inputpc

#This is when it actually writes the command to the serial port.
ser.write(COMMAND)

#all done now close the port.
ser.close()
</pre>
<p>The following is an example of using this script with LIRC, this is a small part of my <em>lircrc </em>file. This map the buttons that I use on my DVICO remote control.</p>
<pre class="brush: plain; title: ; notranslate">
begin
    remote = *
    button = live
    prog   = irexec
    config = tvcontrol --aspect169
end
begin
    remote = *
    button = folder
    prog   = irexec
    config = tvcontrol --aspect43
end
begin
    remote = *
    button = tv_onoff
    prog   = irexec
    config = tvcontrol --poweron
end
begin
    remote = *
    button = power_onoff
    prog   = irexec
    config = tvcontrol --poweroff
end
begin
    remote = *
    button = dtv
    prog   = irexec
    config = tvcontrol --inputdtv
end
begin
    remote = *
    button = mp3
    prog   = irexec
    config = tvcontrol --inputav1
end
begin
    remote = *
    button = dvd
    prog   = irexec
    config = tvcontrol --inputcomp
end
begin
    remote = *
    button = cpf
    prog   = irexec
    config = tvcontrol --inputpc
end
</pre>
<p>You mileage my vary, you will need to understand how your remote control functions and what the current button assignments are.</p>
<p>Another possiblity is to have the tvcontrol script run via a Cron entry or controlled via a webpage, use your mobile phone as a remote instead. The possiblities are endless. Have Fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thelazysysadmin.net/2009/05/rs232-control-lg-lcd-tv-mythtv/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

