[mythtv-users] DataDirect & DirecTV Local Channels

mongo at bambam.homeip.net mongo at bambam.homeip.net
Fri Jul 2 16:22:09 EDT 2004


> On Sat, Jun 26, 2004 at 07:38:22PM -0400, Buechler, Mark R wrote:
>> Zap2it doesn't show local channel linups for DirecTV,
>
> Yes, they do.  At least for me...
>
> If DirecTV only recently added the option of local channels for your
> area, perhaps zap2it hasn't caught up yet.  I'd suggest you try again to
> see if the channels are listed now, and if they're not, ask them about
> it.
>
> -rick
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>

This looks like a good spot to share this.  I've managed to dump all my
Directv tivos and switched over to mythtv. Its a good thing that I'm a
packrat and kept my old IRDs. BUT I had one problem. One IRD was the newer
gen model and had my locals remapped to the lower channels I.E. 3, 8, 10,
13 etc.  But I also had an older model with the same local channels going
to 884, 885, 886. You can't add a new line-up to zapit using the same
source, and I didn't see a way I could change it in mythtv, so I've done
the next best thing. I've changed sony.pl to change the locals to the
upper number. starting at line 76 you will see this:

    if ($channel == "3") {
	$channel="884";
    }

If Mythtv wants channel 3, the script will change to 884. This makes it
all nice and clean with all locals using the same channel numners. just
modify to your channels and have fun.


Enjoy
Pat


-------------- next part --------------
#!/usr/bin/perl

# ORIGINALLY:
# dss_control:  Remote control of a Sony DSS unit via the serial port
# By Josh Wilmes (http://www.hitchhiker.org/dss)
# Based on info from http://www.isd.net/mevenmo/audiovideo.html
#
# I take no responsibility for any damage this script might cause.  
# Feel free to modify and redistribute this as you see fit, but please retain
# the comments above.
#
# BASED ON:
# sony.pl - Found at tarek.2y.net/myth/ 
#
# CURRENTLY:
# sony_dss.pl - Found at http://www.themonkeys.net/myth/sony_dss.pl
# 11.30.2003 Modifications By Michael Maley
# - Added explicit power_on call to ensure receiver is on for recording.
# - Added check_channel to prevent unnecessary channel change. 
#   Based on info from http://home.att.net/~mevenmo/sonydsscodes.html



$|=1;
use POSIX qw(:termios_h);
use FileHandle;

$verbose=0;

%pkt_decode=("0xF0" => "START PKT",
	     "0xF1" => "ERR 1",
	     "0xF2" => "GOT EXTENDED",
	     "0xF4" => "END PKT",
	     "0xF5" => "ERR 2",
	     "0xFB" => "PROMPT");

%terminal=("0xF1" => -1,
	   "0xF4" => 1,
	   "0xF5" => -1);


%keymap=(right => "0x9a",
  	  left => "0x9b",
	    up => "0x9c",
	  down => "0x9d",
      favorite => "0x9e",
        select => "0xc3",
	  exit => "0xc5",
	     9 => "0xc6",
	     8 => "0xc7",
	     7 => "0xc8",
	     6 => "0xc9",
	     5 => "0xca",
	     4 => "0xcb",
	     3 => "0xcc",
	     2 => "0xcd",
	     1 => "0xce",
	     0 => "0xcf",	 
	 ch_up => "0xd2",
	 ch_dn => "0xd3",
	 power => "0xd5",
	  jump => "0xd8",
	 guide => "0xe5",
	  menu => "0xf7");

my $serial=init_serial("/dev/ttyS0","115200");



$ret=&change_channel(@ARGV);
exit(0);

sub change_channel { 
    my ($channel)=@_;

    if ($channel == "3") {
	$channel="884";
    }

    if ($channel == "8") {
	$channel="885";
    }
    
    if ($channel == "10") {
	$channel="886";
    }

    if ($channel == "13") {
	$channel="887";
    }

    if ($channel == "16") {
	$channel="888";
    }

    if ($channel == "22") {
	$channel="889";
    }

    if ($channel == "28") {
	$channel="890";
    }

    if ($channel == "32") {
	$channel="891";
    }

    if ($channel == "38") {
	$channel="892";
    }

    if ($channel == "44") {
	$channel="893";
    }

    if ($channel == "50") {
	$channel="894";
    }

    if ($channel == "62") {
	$channel="895";
    }
        
    &power_on;
    if ($channel != &check_channel) {
	print ("Changing channel to $channel.\n") if ($verbose);
	$_=sprintf("%4.4x",$channel);
	($n1,$n2)=/(..)(..)/;
	simple_command("0x46",$n1,$n2,"0x0");
    }
}

sub power_on {
    dss_command("0x02");
}

sub check_channel {
    @currentChannel = dss_command("0x07");

    print "Current Channel is: @currentChannel[0] \n" if ($verbose);
    return (@currentChannel[0]);
}


sub simple_command {
    if (defined(dss_command(@_))) {
	return(1);
    } else {
	return(undef);
    }
}

sub dss_command {
    sendbytes("0xFA", at _);
    return get_reply();
}


sub sendbytes {
    (@send)=@_;
    foreach (@send) { s/^0x//g; $_=hex($_); }
    print "SEND: " if ($verbose);
    foreach $num (@send) {
	$str=pack('C',$num);
	printf("0x%X [%s] ", $num, $str) if ($verbose);
      syswrite($serial,$str,length($str));
    }
    print "\n" if ($verbose);
}
	      
sub get_reply {
    my $starttime=time();
    my ($last,$ok, at ret);

    print "RECV: " if ($verbose);

    while (1) {       
       $ret=sysread($serial,$buf,1);
       $str=sprintf("0x%2.2X", ord($buf));       

       # busy wait bad!
       die ("Error ($str)\n") if (time() - $starttime > 8);
       next if $str eq "0x00";
       
       if ($pkt_decode{$str}) {
	   print $str if ($verbose);
	   print "[$pkt_decode{$str}] " if ($verbose);
       } else {
	   $_=$str; s/^0x//g; $_=hex($_);  
	   printf("$str(%3.3s) ",$_) if ($verbose);
	   push (@ret,$_); 
       }
       
       $ok=1 if ($terminal{$str} > 0);
       last if ($terminal{$str});
       last if ($last eq "0xFB" && $str eq "0xFB");
       $last=$str;
   }
   print "\n\n" if ($verbose);
    
   return @ret if ($ok);
   return undef;
}

sub init_serial {
    my($port,$baud)=@_;
    my($termios,$cflag,$lflag,$iflag,$oflag);
    my($voice);
 
    my $serial=new FileHandle("+>$port") || die "Could not open $port: $!\n";
    
    $termios = POSIX::Termios->new();
    $termios->getattr($serial->fileno()) || die "getattr: $!\n";
    $cflag= 0 | CS8 | HUPCL | CREAD | CLOCAL;
    $lflag= 0;
    $iflag= 0 | IGNBRK | IGNPAR | IXON | IXOFF;
    $oflag= 0;
    
    $termios->setcflag($cflag);
    $termios->setlflag($lflag);
    $termios->setiflag($iflag);
    $termios->setoflag($oflag);
    $termios->setattr($serial->fileno(),TCSANOW) || die "setattr: $!\n";
    eval qq[
	    \$termios->setospeed(POSIX::B$baud) || die "setospeed: \$!\n";
	    \$termios->setispeed(POSIX::B$baud) || die "setispeed: \$!\n";
	    ];
    
    die $@ if $@;
    
    $termios->setattr($serial->fileno(),TCSANOW) || die "setattr: $!\n";
    
    # This gets rid of all the special characters..
    $termios->getattr($serial->fileno()) || die "getattr: $!\n";	
    for (0..NCCS) {	
	if ($_ == NCCS) { last; }
	
	# Dont mess up XON/XOFF..
	if ($_ == VSTART || $_ == VSTOP) { next; }
	
	$termios->setcc($_,0);	
    }
    $termios->setattr($serial->fileno(),TCSANOW) || die "setattr: $!\n";
    
    return $serial;
}
1;


More information about the mythtv-users mailing list