Neil Bird wrote:

> Around about 09/08/05 02:29, Craig Tinson typed ...
>
>> I use redeye serial too.. but with a *very* simple one line bash
>> script.. would be interested in what you've done with redeye.c and
>> the script too..
>
>
>   Okey-doke.  I make no pretention that I'm the original
> author/modifier! The 'digibox.c' [née red_eye.c] and its Makefile I
> purloined from somewhere and then fine-tuned to speed it up
> (near-instant channel changes now).

ditto.
Smaller and perl based.

send_sky_backup
Started from rc5.d/
This sends the Sky 'Backup' and 'Sky' signal every few seconds. This
ensures that no 'red dots' are recorded and it powers on the digibox if
it's had a s/w update.
The locking allows the channel change to take place without colliding.
change_channel
Used as Myth's external channel changer.
The channel change sends the digits. Then tries to 'erase' them by
pressing 'backup'. Then it resends the digits and 'erases' them again.
This ensures that if either set of channel-change digits doesn't quite
make it they don't hang around for the first N seconds of the recording.

Not missed a channel change in over a year.

David

#!/usr/bin/perl -w

use lib '/myth/bin/';
use ir;

my $chan=join(" ", split(//,$ARGV[0]));

# There's a problem in live TV if you change channel rapidly

exit if fork;

get_lock || die "No lock to change to $chan : $!\n";

print "Sending $chan\n";
system "irsend SEND_ONCE SKY SKY BACKUP BACKUP $chan";
sleep 0.5;
system "irsend SEND_ONCE SKY SKY BACKUP BACKUP BACKUP";
sleep 0.5;
system "irsend SEND_ONCE SKY SKY BACKUP BACKUP $chan";
sleep 0.5;
system "irsend SEND_ONCE SKY SKY BACKUP";

clear_lock;

# a couple of useful utility functions for locking during IR activity
use Fcntl;

my $MAX_TRIES = 10;
my $LOCK_FILE="/tmp/ir_lock";

sub get_lock() {
  my $tries = 0;
  while (-f $LOCK_FILE && $tries < $MAX_TRIES ) {
    sleep 1;
    $tries ++;
  }
  return 0 if $tries == $MAX_TRIES ;
  sysopen(IR_LCK, $LOCK_FILE, O_RDWR | O_EXCL | O_CREAT) || return 0;
  return 1;
}

sub clear_lock() {
    close IR_LCK;
    unlink($LOCK_FILE);
}

1;
#!/usr/bin/perl -w

use lib '/myth/bin/';
use ir;

while (1)
{
  sleep 5;
  get_lock && do {
    system "irsend SEND_ONCE SKY BACKUP SKY";
    clear_lock;
  }
}
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users

Reply via email to