sat

PerlOscScript

The purpose is to get data from predict and send them as OSC fromatted data.

nb: it is not possible to broadcast with Net::OpenSoundControl::Client therefore we open a broadcast socket with IO::Socket::Inet

the source so far:

   1 #!/usr/bin/perl -w
   2 #
   3 # osc.pl: fetch data of a satellite from predict
   4 # and send them over osc
   5 #
   6 #
   7 # TODO use telnet
   8 use IO::Socket;
   9 use strict;
  10 $| =1;
  11 
  12 use Net::OpenSoundControl::Client;
  13 
  14 # TODO finde richtiges subnetz
  15 my $client = IO::Socket::INET->new(
  16         PeerAddr => inet_ntoa(INADDR_BROADCAST),
  17         PeerPort => 7777,
  18         Broadcast => 1,
  19         Proto => 'udp') or die('could not connect.');
  20 
  21 # socket to predict
  22 # you must start predict -s first!
  23 # default settings: localhost ,port 1210 UDP
  24 
  25 my $sock = new IO::Socket::INET(
  26         PeerAddr => 'localhost',
  27         PeerPort => 1210,
  28         Proto => 'udp', Timeout => 1) or die('could not connect.');
  29 # parameters returned from GET_SAT
  30 my @dn = qw(name long lat az el next foot slantrange alt velo nr vis phase ecl squint);
  31 
  32 # satelites we want to query about
  33 my @satellites= qw(LUSAT ITAMSAT OSCAR-27 OSCAR-50 CUTE-1 PCSAT HAMSAT NOAA-14 NOAA-15 NOAA-17 HUBBLE ISS);
  34 
  35 my $qry = 'GET_SAT ';
  36 
  37 # main loop
  38 while() {
  39 
  40         foreach (@satellites) {
  41 
  42                 my $mysat = $_;
  43                 my $myq = $qry.$mysat;
  44 
  45                         for (my $n =0; $n<15; $n++) {
  46                                 print $sock $myq;
  47                                 my $d = <$sock>;
  48                                 chomp $d;
  49                         #       print " $dn[$n]: $d";
  50                         #       print "\n";
  51                                 if ($n != 11 && $n !=0 ) {
  52                                         my @d=['/sat/'.$mysat.'/'.$dn[$n],'f', $d];
  53                                        $client-> send(Net::OpenSoundControl::encode(@d));
  54                                 }
  55                         }
  56                 # cool down, wait for 0.1 sec
  57                 select (undef, undef, undef, 0.1);
  58         }
  59 }

sat: PerlOscScript (last edited 2011-06-25 17:15:49 by NorbertMath)