#!/usr/bin/perl use IO::Socket; sub open_socket { $sock = new IO::Socket::INET ( PeerAddr => '219.89.117.147', PeerPort => '4000', Proto => 'tcp', ); die "Could not create socket: $!\n" unless $sock; # so output gets there right away $sock->autoflush(1); printf "Socket opened to DBBC\n"; } sub close_socket { close($sock); printf "Closed socket to DBBC\n"; } #MAIN ========================================================================== # Usage if ($#ARGV != 0 ) { print "$#ARGV\n"; print "usage: perl dbbc.pl filename.skd\n"; exit; } # The following are the freq's used to mix down for x & s band. # These are used to determine the centre freq of the band $xmix=7600; $smix=1900; open_socket; #open(SCHEDFILE,") { my($line)=$_; chomp($line); if($line=~ m/^C SX X/ || $line=~ m/^C SX S/ || $line=~ m/^C 8F/ ) { my @values=split(' ',$line); # printf "$values[5] $values[2] $values[3] $values[7]\n"; @dbbc = ($values[5],$values[2],$values[3],$values[7]); # Print out cfreq and bandwidths # printf " $dbbc[2] $dbbc[3] \n"; # Work out centre freq for dbbcnn command # CFREQ = Freq - mix if($dbbc[1]=~/X/) { $cfreq=$dbbc[2]-$xmix; } else { $cfreq=$dbbc[2]-$smix; } # printf "Centre Freq = $cfreq\n"; push(@dbbc,$cfreq); # Depending on centre freq we have to use different filters # Used by dbbcif command # filter=> 2(10-512MHz), 1(512-1024MHz), 3(ext1), 4(1024-1536MHz) if($cfreq > 1024) { $filter=4; } elsif ($cfreq > 512) { $filter=1; } elsif ($cfreq > 10) { $filter=2; } # printf "Filter = $filter\n"; push(@dbbc,$filter); push @AoA,[@dbbc]; } } # Program each channel on the DBBC - Down Converter Configuration # for $aref ( @AoA ) { # print "\t @$aref \n"; for $i ( 0 .. $#AoA) { $channel=$AoA[$i][0]; $freq=$AoA[$i][4]; $bwd=$AoA[$i][3]; if($channel<10) { printf "DBBC Command > dbbc0$channel=$freq,a,$bwd,$bwd,1,agc,1\n"; print $sock "dbbc0$channel=$freq,a,$bwd,$bwd,1,agc,1\0"; $sock->recv($reply,1024); print "DBBC Response < $reply\n"; } else { printf "DBBC Command > dbbc$channel=$freq,a,$bwd,$bwd,1,agc,1\n"; print $sock "dbbc$channel=$freq,a,$bwd,$bwd,1,agc,1\0"; $sock->recv($reply,1024); print "DBBC Response < $reply\n"; } } # Now set the filters for the IF's - Set Core Module $filter=$AoA[0][5]; printf "DBBC Command > dbbcifa=1,agc,$filter\n"; print $sock "dbbcifa=1,agc,$filter\0"; $sock->recv($reply,1024); print "DBBC Response < $reply\n"; $filter=$AoA[5][5]; printf "DBBC Command > dbbcifb=1,agc,$filter\n"; print $sock "dbbcifb=1,agc,$filter\0"; $sock->recv($reply,1024); print "DBBC Response < $reply\n"; $filter=$AoA[9][5]; printf "DBBC Command > dbbcifd=1,agc,$filter\n"; print $sock "dbbcifd=1,agc,$filter\0"; $sock->recv($reply,1024); print "DBBC Response < $reply\n"; $filter=$AoA[13][5]; printf "DBBC Command > dbbcifc=1,agc,$filter\n"; print $sock "dbbcifc=1,agc,$filter\0"; $sock->recv($reply,1024); print "DBBC Response < $reply\n"; close_socket;