[aprssig] PERL code to talk to predict and control rotator

Andrew Rich vk4tec at tech-software.net
Fri Sep 2 08:48:07 EDT 2005


Howdy,

Playing with a 24 volt rotator, 1 second on = 6 deg movement.

Here is the code I am playing with talks to predict

#!/usr/bin/perl
use Socket;
use Net::Telnet;
$posnow = $ARGV[0];
my $port = 1210;
my ($predict_server, $satellite);
$satellite ="ISS";
$predict_server = "localhost";
my ($d1, $d2, $d3, $d4, $rawserver) = gethostbyname($predict_server);
my $serveraddr = pack("Sna4x8", 2, $port, $rawserver);
my $prototype = getprotobyname('udp');

while ()
{

socket(SOCKET,2,SOCK_DGRAM,$prototype) || die("No Socket\n");
$| = 1;  # no buffering
$SIG{ALRM} = \&time_out;
alarm(10);  # Force exit if no response from server
send(SOCKET, "GET_SAT $satellite\0" , 0 , $serveraddr) or die("UDP send
failed $!\n");
my $server_response = '';  # required by recv function
recv(SOCKET, $server_response, 100, 0) or die "UDP recv failed $!\n";
my ($name, $lon, $lat, $az, $el, $aos_seconds, $foot) = split /\n/,
$server_response;
my $aos_time_date = gmtime($aos_seconds);
close(SOCKET);

$az = int($az);
# Work out how to turn

# print "The rotator is at $posnow predict is at $az \n";

$dif = $posnow - int($az);
# print "Thats a diff of $dif \n";

if (abs($dif) > 5)
{

# print "The rotator is at $posnow predict is at $az \n";

if ($dif < 1)
{
# print "Going clock wise for ".($dif/6)." secs \n";
# print "Turning on clock wise relay \n";
print "The rotator is at $posnow predict is at $az - Clock wise on \n";
;
sleep 1;
$posnow = $posnow + 6;
}
elsif ($dif > 1)
{
# print "Going counter clock wise for ".($dif/6)." secs \n";
# print "Turning on counter clock wise relay\n";
print "The rotator is at $posnow predict is at $az - Counter Clock wise on
\n";
sleep 1;
$posnow = $posnow - 6;
}

}

sleep 1;
}

sub time_out
{
die "Server not responding for satellite $satellite\n";
}






More information about the aprssig mailing list