[OZAPRS] Google earth server on Raspberry Pi ( perl script )

Andrew Rich vk4tec at tech-software.net
Mon Apr 1 02:17:53 EST 2013


Here is the perl script that connects to the APRS-IS and inserts data into a MySQL table.

It uses DBI, Net::Telnet and Ham::APRS::FAP

//

#!/usr/bin/perl
#
# Amateur Radio APRS packer Parser
#
use DBI;
use Net::Telnet;
use Ham::APRS::FAP qw(parseaprs);
my $database_handler =  DBI->connect("DBI:mysql:database=aprs;host=localhost;port=3306","root","");
my $host = "first.aprs.net.au";
my $port = "14579";
#my $port = "10152";
my $t = new Net::Telnet(Timeout => '600',Dump_log => 'dump.log',Input_log => 'input.log',Output_log => 'output.log',Prompt => "/$prmt/");
$t->errmode('die');
$t->Net::Telnet::open(Host => $host, Port => $port);
print $t "user callsign pass 12345 vers perl script filter p/VK\n";
while (<$t>)
{
my $aprspacket = $_;
my %packetdata;
my $retval = parseaprs($aprspacket, \%packetdata);
if ($retval == 1)
{
while (my ($key, $value) = each(%packetdata))
{
#print $key;
#print "$key: $value\n";
if ($key eq "srccallsign")
{
$callsign = ($value);
}
if ($key eq "latitude")
{
$latitude = ($value);
}
if ($key eq "longitude")
{
$longitude = ($value);
}
if ($key eq "comment")
{
$comment = ($value);
}
if ($key eq "type")
{
$type = ($value);
}
}
#print "Call: $callsign Lat: $latitude Lon: $longitude \n";
#
# MySQL database
#
if ($type =~ m/location/)
{
print "Call: $callsign Lat: $latitude Lon: $longitude \n";
$sql = "delete from aprs_targets where callsign = '$callsign'" ;
$statement_handler =$database_handler->prepare ($sql);
$statement_handler->execute ;
$sql = "insert into aprs_targets values (now(),'$callsign','$latitude','$longitude')" ;
$statement_handler =$database_handler->prepare ($sql);
$statement_handler->execute ;
}
}
else
{
warn "Parsing failed: $packetdata{resultmsg} ($packetdata{resultcode})\n";
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.aprs.net.au/pipermail/ozaprs/attachments/20130401/31de9b77/attachment.html>


More information about the OZAPRS mailing list