View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 6 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Tue Sep 27, 2005 9:02 pm 
Offline
Joined: Thu Feb 24, 2005 2:50 am
Posts: 60
I just assembled a little HD44780-based LCD display that uses the LCDd driver and built it into the front of my Myth box (I ran the parallel cable through the inside of the case). Instructions for LCDd and wiring up such a display are available here: http://lcdproc.omnipotent.net/

As mentioned elsewhere, of course LCDd support is already in Knoppmyth (thanks Cesman!) but you must configure LCDd.conf and start LCDd, perhaps via a line like this in bootmisc.sh:
Quote:
/etc/init.d/LCDd start


After getting it all working, I thought the LCD display was neat, but using setup in MythTV 0.18 I could not find any option to display TV program titles on the LCD display as they are being recorded. For example, my wife asks if program X is being recorded and we'd end up having to turn on the TV (or stop watching something else) to make sure -- but not anymore...

Perhaps there's a better way to do this, but below is a little perl script I wrote that goes through the mythbackend.log file and displays the title of the last 2 shows that started recording (today) and the time that the recording started.

To use it, save the text below as "/usr/local/bin/lcdrec.pl" and use "chmod a+x lcdrec.pl" to make it executable (you might also have to fix the end-line characters since this was pasted via windows). Then go into webmin and set up a crontab entry to make it execute at 00 and 30 minutes past the hour, every hour. Also, be sure to disable the LCD support in the mythfrontend so it doesn't overwrite what's displayed on the screen.

9/29 UPDATE: To use this, you must also modify /etc/init.d/LCDd to add "-i" to DAEMON_OPTS, so that LCDd does not revert back to the server screen when no TCP clients are connected. For example:
Quote:
DAEMON_OPTS="-i -s -f -c /etc/LCDd.conf"


I hope someone else finds this useful.


Quote:
#!/usr/bin/perl -w
#
# lcdrec.pl - display MythTV recording programs to a VFD/LCD display
# Mark Thompson 2005
#
# Use webmin to add a crontab entry to execute this at 00 and 30
# minutes past each hour
#
use IO::Socket;
use Fcntl;
use strict;

my $path = "/var/log/mythtv/mythbackend.log";

# Sleep a few seconds to make sure that myth logfile has been updated;
sleep 10;

# Open mythbackend.log to check recording history
sysopen( LOGFILE, $path, O_RDONLY | O_NONBLOCK ) || die "Cannot read logfile $path\n";

# Open TCP port to LCDd
my $remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "localhost",
PeerPort => 13666)|| die "Cannot connect to LCDd\n";
$remote->autoflush(1);
sleep 1; # give the server time to notice us...
print $remote "hello\n";
# we must read the response even if we ignore it:
my $lcdresponse = <$remote>;
# Turn off blocking mode...
fcntl($remote, F_SETFL, O_NONBLOCK);
# Set up some screen widgets...
print $remote "client_set name lcdmsg\n";
$lcdresponse = <$remote>;
print $remote "screen_add scr1\n";
$lcdresponse = <$remote>;
print $remote "screen_set scr1 -duration 10 -priority 2 -heartbeat off\n";
$lcdresponse = <$remote>;
print $remote "widget_add scr1 wid1 string\n";
$lcdresponse = <$remote>;
print $remote "widget_add scr1 wid2 string\n";
$lcdresponse = <$remote>;
#
my $s;
my $t;
my $l1;
my $l2;
while( $s = <LOGFILE> )
{
if ($s =~ /scheduler:/) {}
else
{
#(move this # to the next line down if you want to finished recordings
#to be displayed as well:)
# if ($s =~ /recording/)
if ($s =~ /Started recording/)
{
$t = substr($s, 11, 5);
if ($s =~ /Started recording/) {
$s = substr($s, index($s, "Started recording")+18);
$s = "$t $s";
} else
{
if ($s =~ /Finished recording/) {
$s = substr($s, index($s, "Finished recording")+19);
$s = "$t f:$s";
}
}
$_ = substr($s, 0, rindex($s, " on channel"));
tr/"'//d;
$l1=$l2; $l2=$_;
}
}
}
close(LOGFILE);

# I'm assuming here that the LCD is only 2 lines
if ($l1)
{
print $remote "widget_set scr1 wid1 1 1 \"$l1\"\n";
$lcdresponse = <$remote>;
}

if ($l2)
{
print $remote "widget_set scr1 wid2 1 2 \"$l2\"\n";
$lcdresponse = <$remote>;
}

# sleep so TCP connection will stay open until LCD has been updated
sleep 5;


Last edited by no2u on Thu Sep 29, 2005 4:46 am, edited 1 time in total.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 9:24 pm 
Offline
Joined: Fri Sep 19, 2003 7:05 pm
Posts: 5088
Location: Fontana, Ca
:)
You're welcome. Cool little program!

_________________
cesman

When the source is open, the possibilities are endless!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 03, 2006 10:10 pm 
Offline
Joined: Tue Oct 25, 2005 3:51 pm
Posts: 69
I ran through al the steps to run this with the exception of editing /etc/crontab to get lcdrec.pl to run every half hour.

Could some show me the edits that need to be made to /etc/crontab in order to

Quote:
set up a crontab entry to make it execute at 00 and 30 minutes past the hour, every hour.


I looked at it, but I'm not sure what to write where...

Code:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file.
# This file also has a username field, that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || run-parts --report /etc/cron.daily
47 6    * * 7   root    test -x /usr/sbin/anacron || run-parts --report /etc/cron.weekly
52 6    1 * *   root    test -x /usr/sbin/anacron || run-parts --report /etc/cron.monthly
#



Thanks much!

_________________
R5D1 MythTV 0.20
AMD Sempron 64 2600+
Biostar K8NHA mobo w/nForce3
Chaintech SH5200 vcard w/128 MB
Hauppauge PVR500 MCE
1 GB DDR 400
300 GB IDE Seagate HD
NEC 3550A DL DVD burner
BTC 9019URF wireless keyboard
WMP54G Linksys Wireless NIC


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 03, 2006 10:24 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
Kamy wrote:
Code:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file.
# This file also has a username field, that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || run-parts --report /etc/cron.daily
47 6    * * 7   root    test -x /usr/sbin/anacron || run-parts --report /etc/cron.weekly
52 6    1 * *   root    test -x /usr/sbin/anacron || run-parts --report /etc/cron.monthly
#

Add a line like this:
Code:
0,30 * * * * root /the/full/path/to/your/script/here.pl


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 4:29 am 
Offline
Joined: Tue Oct 25, 2005 3:51 pm
Posts: 69
Thanks tjc,

I'll give it a shot after work today.

_________________
R5D1 MythTV 0.20
AMD Sempron 64 2600+
Biostar K8NHA mobo w/nForce3
Chaintech SH5200 vcard w/128 MB
Hauppauge PVR500 MCE
1 GB DDR 400
300 GB IDE Seagate HD
NEC 3550A DL DVD burner
BTC 9019URF wireless keyboard
WMP54G Linksys Wireless NIC


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 7:11 pm 
Offline
Joined: Thu Feb 24, 2005 2:50 am
Posts: 60
FYI, you can also set up crontab jobs via webmin: While running webmin, select the "System" tab, then select "Scheduled Cron Jobs", then "Create a new cron job". Enter "root" as the user to execute this cron job, enter the full path to the command, click "Selected" under minutes, then choose 1 and 31 under Minutes. (I've selected 1 and 31 minutes past each hour since some networks like to start shows at one minute past the hour).


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 74 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu