'''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:

{{{#!highlight perl
#!/usr/bin/perl -w
#
# osc.pl: fetch data of a satellite from predict
# and send them over osc
#
#
# TODO use telnet
use IO::Socket;
use strict;
$| =1;

use Net::OpenSoundControl::Client;

# TODO finde richtiges subnetz
my $client = IO::Socket::INET->new(
        PeerAddr => inet_ntoa(INADDR_BROADCAST),
        PeerPort => 7777,
        Broadcast => 1,
        Proto => 'udp') or die('could not connect.');

# socket to predict
# you must start predict -s first!
# default settings: localhost ,port 1210 UDP

my $sock = new IO::Socket::INET(
        PeerAddr => 'localhost',
        PeerPort => 1210,
        Proto => 'udp', Timeout => 1) or die('could not connect.');
# parameters returned from GET_SAT
my @dn = qw(name long lat az el next foot slantrange alt velo nr vis phase ecl squint);

# satelites we want to query about
my @satellites= qw(LUSAT ITAMSAT OSCAR-27 OSCAR-50 CUTE-1 PCSAT HAMSAT NOAA-14 NOAA-15 NOAA-17 HUBBLE ISS);

my $qry = 'GET_SAT ';

# main loop
while() {

        foreach (@satellites) {

                my $mysat = $_;
                my $myq = $qry.$mysat;

                        for (my $n =0; $n<15; $n++) {
                                print $sock $myq;
                                my $d = <$sock>;
                                chomp $d;
                        #       print " $dn[$n]: $d";
                        #       print "\n";
                                if ($n != 11 && $n !=0 ) {
                                        my @d=['/sat/'.$mysat.'/'.$dn[$n],'f', $d];
                                       $client-> send(Net::OpenSoundControl::encode(@d));
                                }
                        }
                # cool down, wait for 0.1 sec
                select (undef, undef, undef, 0.1);
        }
}
}}}