#!/usr/bin/perl -w use strict; use Socket; my $port = 1210; my ($predict_server, $satellite); # Use defaults if no command line arguments given if ($#ARGV eq 1) { $predict_server = $ARGV[0]; $satellite = $ARGV[1]; } else { print "WARNING: Use syntax \"sat.pl hostname satellite\" (i.e., sat. +pl localhost FO-20)\n"; print "Substituting default arguments\n"; $predict_server = "localhost"; $satellite = "OSCAR-10"; } # Setup for UDP socket commumnication my ($d1, $d2, $d3, $d4, $rawserver) = gethostbyname($predict_server); my $serveraddr = pack("Sna4x8", 2, $port, $rawserver); my $prototype = getprotobyname('udp'); socket(SOCKET,2,SOCK_DGRAM,$prototype) || die("No Socket\n"); $| = 1; # no buffering # Setup timeout routine $SIG{ALRM} = \&time_out; alarm(10); # Force exit if no response from server # Send request to predict send(SOCKET, "GET_SAT $satellite\0" , 0 , $serveraddr) or die("UDP sen +d failed $!\n"); # Get response from predict my $server_response = ''; # required by recv function recv(SOCKET, $server_response, 100, 0) or die "UDP recv failed $!\n"; # Extract individual responses my ($name, $lon, $lat, $az, $el, $aos_seconds, $foot) = split /\n/, $s +erver_response; my $aos_time_date = gmtime($aos_seconds); # Output response print "\nPREDICT returned the following string in response to GET_SAT +$satellite:\n\n$server_response\n"; print "Values are as follows:\nName: $name\nLong: $lon\nLat: $lat\nAz: + $az\nEl: $el\nNext AOS: $aos_seconds = $aos_time_date UTC\nFootprint +: $foot\n\n"; close(SOCKET); sub time_out { die "Server not responding for satellite $satellite\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Satellite Tracking
by particle (Vicar) on May 14, 2002 at 14:47 UTC | |
|
Re: Satellite Tracking
by brianarn (Chaplain) on May 14, 2002 at 17:40 UTC |