X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Frbn.pl;h=706037807fe9be1ead6f32834f84cde1df06f2cb;hb=10bcae7d964cf5a4b9f7a439c29afff218a35903;hp=670caed54d2e8ef36d1d75e5f94cd789cedee12a;hpb=55d89da47d81b4a66fab966620dacd213b6ca20e;p=spider.git diff --git a/perl/rbn.pl b/perl/rbn.pl index 670caed5..70603780 100755 --- a/perl/rbn.pl +++ b/perl/rbn.pl @@ -25,6 +25,10 @@ my $wantcw = 1; my $wantrtty = 1; my $wantpsk = 1; my $wantbeacon = 1; +my $wantdx = 1; +my $wantft = 1; +my $wantpsk = 1; +my $wantraw = 0; my $showrbn; my $help = 0; my $man = 0; @@ -36,15 +40,19 @@ GetOptions('host=s' => \$host, 'debug' => \$dbg, 'rbn' => \$showrbn, 'stats' => \$showstats, + 'raw' => \$wantraw, 'repeattime|rt=i' => sub { $minspottime = $_[1] * 60 }, 'want=s' => sub { my ($name, $value) = @_; - $wantcw = $wantrtty = $wantpsk = $wantbeacon = 0; + $wantcw = $wantrtty = $wantpsk = $wantbeacon = $wantdx = $wantft = $wantpsk = 0; for (split /[:,\|]/, $value) { ++$wantcw if /^cw$/i; ++$wantpsk if /^psk$/i; ++$wantrtty if /^rtty$/i; - ++$wantbeacon if /^beacon$/i; + ++$wantbeacon if /^beacon/i; + ++$wantdx if /^dx$/i; + ++$wantft if /^ft$/; + ++$wantft, ++$wantrtty, ++$wantpsk if /^digi/; } }, 'help|?' => \$help, @@ -59,7 +67,7 @@ pod2usage(-exitval => 0, -verbose => 2) if $man; for ($attempts = 1; $attempts <= 5; ++$attempts) { - say "admin,connecting to $host $port.. (attempt $attempts) " if $dbg; + say "ADMIN,connecting to $host $port.. (attempt $attempts) " if $dbg; $sock = IO::Socket::IP->new( PeerHost => $host, PeerPort => $port, @@ -68,10 +76,12 @@ for ($attempts = 1; $attempts <= 5; ++$attempts) { last if $sock; } -die "admin,Cannot connect to $host:$port after 5 attempts $!" unless $sock; -say "admin,connected" if $dbg; +die "ADMIN,Cannot connect to $host:$port after 5 attempts $!\n" unless $sock; +say "ADMIN,connected" if $dbg; +$sock->timeout(0); + print $sock "$mycall\r\n"; -say "admin,call sent" if $dbg; +say "ADMIN,call $mycall sent" if $dbg; my %d; my %spot; @@ -86,8 +96,28 @@ while (<$sock>) { my $tim = time; # parse line - my (undef, undef, $origin, $qrg, $call, $mode, $s, $m, $spd, $u, $sort, $t) = split /[:\s]+/; - if ($t) { + say "RAW,$_" if $wantraw; + + if (/call:/) { + print $sock "$mycall\r\n"; + say "ADMIN,call $mycall sent" if $dbg; + } + + my (undef, undef, $origin, $qrg, $call, $mode, $s, $m, $spd, $u, $sort, $t, $tx) = split /[:\s]+/; + my $b; + + if ($t || $tx) { + + # fix up times for things like 'NXDXF B' etc + if ($tx && $t !~ /^\d{4}Z$/) { + if ($tx =~ /^\d{4}Z$/) { + $b = $t; + $t = $tx; + } else { + say "ERR,$_"; + next; + } + } # We have an RBN data line, dedupe it very simply on time, ignore QRG completely. # This works because the skimmers are NTP controlled (or should be) and will receive @@ -100,7 +130,11 @@ while (<$sock>) { $d{$p} = $tim; ++$norbn; $qrg = sprintf('%.1f', nearest(.1, $qrg)); # to nearest 100Hz (to catch the odd multiple decpl QRG [eg '7002.07']). - say join(',', "RBN", $origin, $qrg, $call, $mode, $s, $m, $spd, $u, $sort, $t) if $dbg || $showrbn; + if (!$wantraw && ($dbg || $showrbn)) { + my $s = join(',', "RBN", $origin, $qrg, $call, $mode, $s, $m, $spd, $u, $sort, $t); + $s .= ",$b" if $b; + say $s; + } # Determine whether to "SPOT" it based on whether we have not seen it before (near this QRG) or, # if we have, has it been a "while" since the last time we spotted it? If it has been spotted @@ -108,33 +142,33 @@ while (<$sock>) { my $nqrg = nearest(1, $qrg); # normalised to nearest Khz my $sp = "$call|$nqrg"; # hopefully the skimmers will be calibrated at least this well! my $ts = $spot{$sp}; - + if (!$ts || ($minspottime > 0 && $tim - $ts >= $minspottime)) { - if ($wantbeacon && $sort =~ /^BEA/) { - ; - } else { - # Haven't used a perl 'goto' like this ever! - # Clearly I need to use an event driven framework :-) - goto periodic if !$wantcw && $mode =~ /^CW/; - goto periodic if !$wantrtty && $mode =~ /^RTTY/; - goto periodic if !$wantpsk && $mode =~ /^PSK/; + my $want; + + ++$want if $wantbeacon && $sort =~ /^BEA|NCD/; + ++$want if $wantcw && $mode =~ /^CW/; + ++$want if $wantrtty && $mode =~ /^RTTY/; + ++$want if $wantpsk && $mode =~ /^PSK/; + ++$want if $wantdx && $mode =~ /^DX/; + ++$want if $wantft && $mode =~ /^FT/; + if ($want) { + ++$nospot; + my $tag = $ts ? "RESPOT" : "SPOT"; + $t .= ",$b" if $b; + say join(',', $tag, $origin, $qrg, $call, $mode, $s, $m, $spd, $u, $sort, $t); + $spot{$sp} = $tim; } - - ++$nospot; - my $tag = $ts ? "RESPOT" : "SPOT"; - say join(',', $tag, $origin, $qrg, $call, $mode, $s, $m, $spd, $u, $sort, $t); - $spot{$sp} = $tim; } } else { - say "data,$_" if $dbg; + say "DATA,$_" if $dbg && !$wantraw; } - periodic: # periodic clearing out of the two caches if (($tim % 60 == 0 && $tim > $last) || ($last && $tim >= $last + 60)) { my $count = 0; my $removed = 0; - + while (my ($k,$v) = each %d) { if ($tim-$v > 60) { delete $d{$k}; @@ -143,7 +177,7 @@ while (<$sock>) { ++$count; } } - say "admin,rbn cache: $removed removed $count remain" if $dbg; + say "ADMIN,rbn cache: $removed removed $count remain" if $dbg; $count = $removed = 0; while (my ($k,$v) = each %spot) { if ($tim-$v > $minspottime*2) { @@ -153,7 +187,7 @@ while (<$sock>) { ++$count; } } - say "admin,spot cache: $removed removed $count remain" if $dbg; + say "ADMIN,spot cache: $removed removed $count remain" if $dbg; say join(',', "STAT", $noraw, $norbn, $nospot) if $showstats; $noraw = $norbn = $nospot = 0; @@ -196,10 +230,13 @@ As default, this program will connect to C. Use this a As default, this program will connect to port 7000. Use this argument to change that to some other port. -=item B<-want>=cw,rtty,psk,beacon +=item B<-want>=cw,rtty,dx,beacon,psk,ft,digital + +The program will print all spots in all classes in the 'mode/calling' column [cw, rtty, beacon, dx, psk, ft, digital]. You can choose one or more of +these classes if you want specific types of spots. The class 'digital' is equivalent to [rtty,psk,ft]. The class 'beacon' includes +NCDXF beacons. -The program will print all spots in all classes [cw, rtty, psk, beacon]. You can choose one or more of -these classes if you want specific types of spots. +E.g. rbn.pl -want=psk,ft,beacon g9tst =item B<-stats> @@ -216,6 +253,10 @@ but with a RESPOT tag instead. Set this argument to 0 (or less) if you do not wa Show the de-duplicated RBN lines as they come in. +=item B<-raw> + +Show the raw RBN lines as they come in. + =back =head1 DESCRIPTION @@ -235,5 +276,17 @@ Like this: SPOT,SK3W-#,3600.0,OK0EN,CW,13,dB,11,WPM,BEACON,2152Z STAT,263,64,27 +If the -raw flag is set then these lines will be interspersed with the raw line from the RBN source, prefixed +with "RAW,". For example: + + RAW,DX de PJ2A-#: 14025.4 IP0TRC CW 16 dB 31 WPM CQ 1307Z + RAW,DX de PJ2A-#: 10118.9 K1JD CW 2 dB 28 WPM CQ 1307Z + RAW,DX de K2PO-#: 1823.4 HL5IV CW 8 dB 22 WPM CQ 1307Z + SPOT,K2PO-#,1823.4,HL5IV,CW,8,dB,22,WPM,CQ,1307Z + RAW,DX de LZ7AA-#: 14036.6 HA8GZ CW 7 dB 27 WPM CQ 1307Z + RAW,DX de DF4UE-#: 14012.0 R7KM CW 32 dB 33 WPM CQ 1307Z + RAW,DX de G7SOZ-#: 14012.2 R7KM CW 17 dB 31 WPM CQ 1307Z + + =cut