[aprssig] RE: aprs_packet_mon.pl

Ron Cluster rcluster at rgisp.com
Thu Apr 7 01:54:56 EDT 2005


OK, I guess I'll have to repeat someone elses earlier question....

What is this, and how do I make use of it?

73.....Ron.....AC7TK.....(-9 when mobile)
UI-View32 iGate in Eugene, OR




-----Original Message-----
From: aprssig-bounces at lists.tapr.org
[mailto:aprssig-bounces at lists.tapr.org]On Behalf Of Andrew Rich
Sent: Wednesday, April 06, 2005 5:10 PM
To: TAPR APRS Special Interest Group
Subject: [aprssig] RE: aprs_packet_mon.pl


Chris has added MIC code ....thanks Chris !



Here you go. I'm pretty much done with it - it pulls apart MIC-E and
also gets the position and course out of pretty much everything it can.

Cheers,
chris

#!/usr/bin/perl
#############################################################
#
# APRS Packet disassembly - Andrew Rich VK4TEC - Nov 2004
# 	augmented by Chris Kantarjiev KG6VYD
# $Id: aprs_packet_mon.pl,v 1.4 2005/04/04 23:49:44 cak Exp $
#
#############################################################
my $trace = 1;
use Net::Telnet;
my $host = "concord.aprs.net";
my $user = "";
my $password = "";
my $prompt = "";
my (@data, $line);
my $t = new Net::Telnet(Timeout => '5',port => '10152');
$t->errmode('return');
$t->Net::Telnet::open($host) or die "Connection problem\n";
print $t "user kg6vyd pass -1 vers aprsMon 1.1.2+ \n";
print $t "# filter a/39/-123/37/-121 \n";
while (<$t>)
{
$date=(`date +%d/%m/%Y" "%H:%M:%S`);
chop $date;
#system('clear');
chomp;
@packet=();
@digi=();
@callsign=();
@packet=split(/:/,$_,2);
@digi=split(/>/,$packet[0]);
@callsign=split(/>/,$_);
$email ='';
$webpage='';
$program='';
if (m/.*\s+([a-zA-Z0-9\+_.-]+)\@([a-zA-Z0-9.-]+)\s+/)
{
$email= $1."@".$2;
}
if (m/http:\/\/([a-zA-Z0-9.-]+)\s+/)
{
$webpage = $1;
}

if (m/{UIV32/)
{
$program="UI-View 32 Bit";
}
elsif (m/UI-View32/)
{
$program="UI-View 32 Bit";
}
elsif (m/aprsd/)
{
$program="Linux aprsd server"
}
elsif (m/>APU/)
{
$program="UI-View"
}
elsif (m/>APW/)
{
$program="WinAPRS"
}
elsif (m/>APD/)
{
$program="Linux aprsd server"
}
elsif (m/>APX/)
{
$program="XASTIR"
}
elsif (m/>APZ/)
{
$program="Experimental"
}
elsif (m/DIGI_NED/)
{
$program="Digi - DIGI_NED";
}
# -----------------------------------------------------
if (m/^#/)
{
print "Routine  : 000 - APRS server message\n";
print "DTG      : $date \n";
print "Packet   : $_\n";
}
# -----------------------------------------------------
elsif ($packet[1]=~ m/^\// || $packet[1]=~ m/^@/)
{
print "Routine  : 001 - position report with timestamp";
if ($packet[1] =~ m/^@/) { print " with messaging"; } print "\n";
print "DTG      : $date \n";
print "Packet   : $_\n";
print "From     : $callsign[0]\n";
print "Path     : $digi[1]\n";
print "Data     : $packet[1]\n";
print "Timestamp: ".substr($packet[1],1,7)."\n";
print "Latitude : ".substr($packet[1],8,8)."\n";
print "Symboltb : ".substr($packet[1],16,1)."\n";
print "Lontitude: ".substr($packet[1],17,9)."\n";
print "Symbol   : ".substr($packet[1],25,1)."\n";
if ( substr($packet[1],26,1) eq '_')
{
print "Comment  : \n";
print "Email    : ".$email."\n";
print "WX data  : ".substr($packet[1],27,160)."\n";
print "WindDIR  : ".substr($packet[1],27,3)."\n";
print "WindSPD  : ".substr($packet[1],31,3)."\n";
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
else
{
print "Comment  : ".substr($packet[1],26,160)."\n";
print "Email    : ".$email."\n";
print "Course	: ".substr($packet[1],27,3)."\n";
print "Speed	: ".substr($packet[1],31,3)."\n";
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
}
# -----------------------------------------------------
elsif ($packet[1]=~ m/^!/)
{
print "Routine  : 002 - position report without timestamp\n";
print "DTG      : $date \n";
print "Packet   : $_\n";
print "From     : $callsign[0]\n";
print "Path     : $digi[1]\n";
print "Data     : $packet[1]\n";
print "Timestamp: \n";
print "Latitude : ".substr($packet[1],1,8)."\n";
print "Symboltb : ".substr($packet[1],9,1)."\n";
print "Lontitude: ".substr($packet[1],10,9)."\n";
print "Symbol   : ".substr($packet[1],19,1)."\n";
if ( substr($packet[1],19,1) eq '_')
{
print "Comment  : ".substr($packet[1],20,160)."\n";
print "Email    : ".$email."\n";
print "WX data  : ".substr($packet[1],20,160)."\n";
print "WindDIR  : ".substr($packet[1],20,3)."\n";
print "WindSPD  : ".substr($packet[1],24,3)."\n";
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
else
{
print "Comment  : ".substr($packet[1],20,160)."\n";
print "Email    : ".$email."\n";
if (substr($packet[1],20,1) =~ /[0-9]/) {
	print "Course   : ".substr($packet[1],20,3)."\n";
	print "Speed    : ".substr($packet[1],24,3)."\n";
} else {
	print "Course   : \n";
	print "Speed    : \n";
}
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
}
# -----------------------------------------------------
elsif ($packet[1]=~ m/^=/)
{
print "Routine  : 003 - position report without timestamp with messaging\n";
print "DTG      : $date \n";
print "Packet   : $_\n";
print "From     : $callsign[0]\n";
print "Path     : $digi[1]\n";
print "Data     : $packet[1]\n";
print "Timestamp: \n";
print "Latitude : ".substr($packet[1],1,8)."\n";
print "Symboltb : ".substr($packet[1],9,1)."\n";
print "Lontitude: ".substr($packet[1],10,9)."\n";
print "Symbol   : ".substr($packet[1],19,1)."\n";
if ( substr($packet[1],19,1) eq '_')
{
print "Comment  : ".substr($packet[1],20,160)."\n";
print "Email    : ".$email."\n";
print "WX data  : ".substr($packet[1],20,160)."\n";
print "WindDIR  : ".substr($packet[1],20,3)."\n";
print "WindSPD  : ".substr($packet[1],24,3)."\n";
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
else
{
print "Comment  : ".substr($packet[1],20,160)."\n";
print "Email    : ".$email."\n";
if (substr($packet[1],20,1) =~ /[0-9]/) {
	print "Course   : ".substr($packet[1],20,3)."\n";
	print "Speed    : ".substr($packet[1],24,3)."\n";
} else {
	print "Course   : \n";
	print "Speed    : \n";
}
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
}
# -----------------------------------------------------
elsif ($packet[1]=~ m/^:/)
{
print "Routine  : 005 - aprs message\n";
print "DTG      : $date \n";
print "Packet   : $_\n";
print "From     : $callsign[0]\n";
print "Path     : $digi1[0]\n";
print "Data     : $packet[1]\n";
print "Timestamp: \n";
print "Latitude : \n";
print "Symboltb : \n";
print "Lontitude: \n";
print "Symbol   : \n";
print "Comment  : \n";
print "Email    : ".$email."\n";
print "WX data  : \n";
print "WindDIR  : \n";
print "WindSPD  : \n";
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
# -----------------------------------------------------
elsif ($packet[1]=~ m/^`/ || $packet[1]=~ m/^'/)
{
print "Routine  : 006 - position report compressed\n";

# see http://www.tapr.org/tapr/html/Fmic-e.html for MIC-E format details
# but see http://www.aprs-is.net/javAPRS/mice_parser.htm for reality

my ($lat, $long) = ("<compressed>", "<compressed>");
my ($latdeg, $longdeg) = (0,0);
my ($latmin, $longmin) = (0,0);
my ($lathun, $longhun) = (0,0);
my $longhund = 0;
my ($north, $west) = (0,0);
my ($symboltb, $symbol);
my ($speed, $heading) = ("", "");
my $j = 0;


sub cnvtDest(@) {
	my $inchar = @_[0];
	my $c = ($inchar - 0x30);		# adjust to be 0 based
	if ($c == 0x1c) { $c = 0x0a; }		# change L to be space
	if ($c > 0x10 && $c <= 0x1b) { $c--; }	# A-K get decremented
						# we don't support ambiguity
	if (($c & 0x0f) == 0x0a) { $c &= 0xf0; }# convert space to 0
	return $c;
}

# ignore the SSID, if any
my @nibs = unpack("c6", $digi[1]);

my $isCustom = 0;
if (($nibs[0] >= ord('A') && $nibs[0] <= ord('K')) ||
    ($nibs[1] >= ord('A') && $nibs[1] <= ord('K')) ||
    ($nibs[2] >= ord('A') && $nibs[2] <= ord('K'))) {
	$isCustom = 1;
}

for ($j = 0; $j < 3; $j++) {
	if ($isCustom) {
		if ($nibs[$j] < ord('0') ||
		    $nibs[$j] > ord('L') ||
		    ($nibs[$j] > ord('9') && $nibs[$j] < ord('A'))) {
			goto MICE;
		}
	} else {
		if ($nibs[$j] < ord('0') ||
		    $nibs[$j] > ord('Z') ||
		    ($nibs[$j] > ord('9') && $nibs[$j] < ord('L')) ||
		    ($nibs[$j] > ord('L') && $nibs[$j] < ord('P'))) {
			goto MICE;
		}
	}
}

for (;$j < 6; $j++) {
	if ($nibs[$j] < ord('0') ||
	    $nibs[$j] > ord('Z') ||
	    ($nibs[$j] > ord('9') && $nibs[$j] < ord('L')) ||
	    ($nibs[$j] > ord('L') && $nibs[$j] < ord('P'))) {
		goto MICE;
	}
}

# parse the TO field
my $c = cnvtDest(@nibs[0]);
my $mes = 0;
if (($c & 0x10) != 0) { $mes = 0x08; }	# set custom flag
if ($c > 0x10) { $mes += 0x04; }
$latdeg = ($c & 0x0f) * 10;

$c = cnvtDest($nibs[1]);
if ($c > 0x10) { $mes += 0x02; }
$latdeg += ($c & 0x0f);

$c = cnvtDest($nibs[2]);
if ($c > 0x10) { $mes ++; }
$mes = ~$mes & 0x7;			# is sent in one's comp?
$latmin = ($c & 0x0f) * 10;

$c = cnvtDest($nibs[3]);
if ($c >= 0x20) { $north = 1; }
$latmin += ($c & 0x0f);

$c = cnvtDest($nibs[4]);
if ($c > 0x20) { $longhund = 1; }
$lathun = ($c & 0x0f) * 10;

$c = cnvtDest($nibs[5]);
if ($c >= 0x20) { $west = 1; }
$lathun += ($c & 0x0f);

$lat = sprintf("%d%02d.%02d", $latdeg, $latmin, $lathun);
if ($north) { $lat .= "N"; } else { $lat .= "S"; }

my @nibs = unpack("c9", $packet[1]);

# parse the icon
$symbol = $nibs[7];
$symboltb = $nibs[8];

# parse the longitude
$longdeg = $nibs[1] - 28;
$longmin = $nibs[2] - 28;
$longsec = $nibs[3] - 28;

if ($longdeg < 0 || $longdeg > 99 ||
    $longmin < 0 || $longmin > 99 ||
    $longsec < 0 || $longsec > 99) {
	goto MICE;
}

# adjust the degrees
if ($longhund) { $longdeg += 100; }
if ($longdeg > 190) {
	$longdeg -= 190;
} elsif ($longdeg >= 180) { $longdeg -= 80; }

# adjust the minutes
if ($longmin >= 60) { $longmin -= 60; }

$long = sprintf("%d%02d.%02d", $longdeg, $longmin, $longhun);
if ($west) { $long .= "W"; } else { $long .= "E"; }

# parse the speed/course

my ($m, $s);

$m = $nibs[5] - 28;
if ($m < 0 || $m > 97) { goto MICE; }
$s = $nibs[4] - 28;
if ($s < 0 || $s > 99) { goto MICE; }
$s = ($s*10) + ($m/10);
if ($s >= 800) { $s -= 800; }

$d = $nibs[6] - 28;
if ($d < 0 || $d > 99) { goto MICE; }
$d = (($m%10) * 100) + $d;
if ($d >= 400) { $d -= 400; }

if ($d > 0) {
	$speed = sprintf("%d", $s);		# speed (knots)
	$heading = sprintf("%d", $d);
}

MICE:
print "DTG      : $date \n";
print "Packet   : $_\n";
print "From     : $callsign[0]\n";
print "Path     : $digi[1]\n";
print "Data     : $packet[1]\n";
print "Timestamp: \n";
print "Latitude : $lat \n";
print "Symboltb : "; printf "%c\n", $symboltb;
print "Lontitude: $long \n";
print "Symbol   : "; printf "%c\n", $symbol;
print "Speed    : $speed \n";
print "Heading  : $heading \n";
print "Comment  : Mic-E message ";
if ($isCustom) { print "<custom>"; } printf "%d\n", $mes;
print "Email    : ".$email."\n";
print "WX data  : \n";
print "WindDIR  : \n";
print "WindSPD  : \n";
print "Webpage  : ".$webpage."\n";
if (m/TMD700/)
{
print "Program  : Tracker - TMD700\n";
}
else
{
print "Program  : Tracker\n";
}
}
# -----------------------------------------------------
elsif ($packet[1]=~ m/^>/)
{
print "Routine  : 007 - status report\n";
print "DTG      : $date \n";
print "Packet   : $_\n";
print "From     : $callsign[0]\n";
print "Path     : $digi[1]\n";
print "Data     : $packet[1]\n";
print "Timestamp: \n";
print "Latitude : \n";
print "Symboltb : \n";
print "Lontitude: \n";
print "Symbol   : \n";
print "Comment  : ".substr($packet[1],1,160)."\n";
print "Email    : ".$email."\n";
print "WX data  : \n";
print "WindDIR  : \n";
print "WindSPD  : \n";
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
# -----------------------------------------------------
elsif ($packet[1]=~ m/^\?/)
{
print "Routine  : 008 - aprs query\n";
print "DTG      : $date \n";
print "Packet   : $_\n";
print "From     : $callsign[0]\n";
print "Path     : $digi[1]\n";
print "Data     : $packet[1]\n";
print "Timestamp: \n";
print "Latitude : \n";
print "Symboltb : \n";
print "Lontitude: \n";
print "Symbol   : \n";
print "Comment  : \n";
print "Email    : ".$email."\n";
print "WX data  : \n";
print "WindDIR  : \n";
print "WindSPD  : \n";
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
# -----------------------------------------------------
elsif ($packet[1]=~ m/^_/)
{
print "Routine  : 009 - positionless weather report \n";
print "DTG      : $date \n";
print "Packet   : $_\n";
print "From     : $callsign[0]\n";
print "Path     : $digi[1]\n";
print "Data     : $packet[1]\n";
print "Timestamp: \n";
print "Latitude : \n";
print "Symboltb : \n";
print "Lontitude: \n";
print "Symbol   : \n";
print "Comment  : \n";
print "Email    : ".$email."\n";
print "WX data  : ".substr($packet[1],1,160)."\n";
print "WindDIR  : \n";
print "WindSPD  : \n";
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
# -----------------------------------------------------
elsif ($packet[1]=~ m/^;/)
{
print "Routine  : 010 - object \n";
print "DTG      : $date \n";
print "Packet   : $_\n";
print "From     : $callsign[0]\n";
print "Path     : $digi[1]\n";
print "Data     : $packet[1]\n";
print "Timestamp: \n";
print "Latitude : \n";
print "Symboltb : \n";
print "Lontitude: \n";
print "Symbol   : \n";
print "Comment  : \n";
print "Email    : ".$email."\n";
print "WX data  : ".substr($packet[1],1,160)."\n";
print "WindDIR  : \n";
print "WindSPD  : \n";
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
# -----------------------------------------------------
elsif ($packet[1]=~ m/^\$GPRMC/)
{
my @nibs = split(/,/, $packet[1]);
print "Routine  : 011 - gps RMC posit \n";
print "DTG      : $date \n";
print "Packet   : $_\n";
print "From     : $callsign[0]\n";
print "Path     : $digi[1]\n";
print "Data     : $packet[1]\n";
print "Timestamp: $nibs[1]\n";
print "Latitude : $nibs[3] $nibs[4]\n";
print "Symboltb : \n";
print "Lontitude: $nibs[5] $nibs[6]\n";
print "Symbol   : \n";
print "Comment  : ";
if ($nibs[2] =~ /V/) { print "no fix!"; } ; print "\n";
print "Speed    : $nibs[7]\n";
print "Heading  : $nibs[8]\n";
print "Email    : ".$email."\n";
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
# -----------------------------------------------------
elsif ($packet[1]=~ m/^\$GPGGA/)
{
my @nibs = split(/,/, $packet[1]);
print "Routine  : 011 - gps GGA posit \n";
print "@nibs \n";
print "DTG      : $date \n";
print "Packet   : $_\n";
print "From     : $callsign[0]\n";
print "Path     : $digi[1]\n";
print "Data     : $packet[1]\n";
print "Timestamp: $nibs[1]\n";
print "Latitude : $nibs[2] $nibs[3]\n";
print "Symboltb : \n";
print "Lontitude: $nibs[4] $nibs[5]\n";
print "Symbol   : \n";
print "Comment  : ";
if ($nibs[2] =~ /0/) { print "no fix!"; } ; print "\n";
print "Email    : ".$email."\n";
print "WX data  : \n";
print "WindDIR  : \n";
print "WindSPD  : \n";
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
# -----------------------------------------------------
elsif ($packet[1]=~ m/^\$GP/)
{
print "Routine  : 011 - raw gps posit \n";
print "DTG      : $date \n";
print "Packet   : $_\n";
print "From     : $callsign[0]\n";
print "Path     : $digi[1]\n";
print "Data     : $packet[1]\n";
print "Timestamp: \n";
print "Latitude : \n";
print "Symboltb : \n";
print "Lontitude: \n";
print "Symbol   : \n";
print "Comment  : ".substr($packet[1],0,160)."\n";
print "Email    : ".$email."\n";
print "WX data  : \n";
print "WindDIR  : \n";
print "WindSPD  : \n";
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
# -----------------------------------------------------
elsif ($packet[1]=~ m/^T/)
{
print "Routine  : 012 - telemetry \n";
print "DTG      : $date \n";
print "Packet   : $_\n";
print "From     : $callsign[0]\n";
print "Path     : $digi[1]\n";
print "Data     : $packet[1]\n";
print "Timestamp: \n";
print "Latitude : \n";
print "Symboltb : \n";
print "Lontitude: \n";
print "Symbol   : \n";
print "Comment  : ".substr($packet[1],0,160)."\n";
print "Email    : ".$email."\n";
print "WX data  : \n";
print "WindDIR  : \n";
print "WindSPD  : \n";
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
# -----------------------------------------------------
elsif ($packet[1]=~ m/^<IGATE/)
{
print "Routine  : 013 - IGATE Status \n";
print "DTG      : $date \n";
print "Packet   : $_\n";
print "From     : $callsign[0]\n";
print "Path     : $digi[1]\n";
print "Data     : $packet[1]\n";
print "Timestamp: \n";
print "Latitude : \n";
print "Symboltb : \n";
print "Lontitude: \n";
print "Symbol   : \n";
print "Comment  : ".substr($packet[1],0,160)."\n";
print "Email    : ".$email."\n";
print "WX data  : \n";
print "WindDIR  : \n";
print "WindSPD  : \n";
print "Webpage  : ".$webpage."\n";
print "Program  : ".$program."\n";
}
# -----------------------------------------------------
else
{
print "Routine  : 099 - Unknown packet\n";
print "DTG      : $date \n";
print "Packet   : $_ \n";
#sleep 15;
}
# -----------------------------------------------------
print "\n";
}
$t->close();





_______________________________________________
aprssig mailing list
aprssig at lists.tapr.org
https://lists.tapr.org/cgi-bin/mailman/listinfo/aprssig





More information about the aprssig mailing list