#!/usr/bin/perl # http://www.kh-gps.de/nmea-faq.htm use strict; while() { chomp; chomp; # $GPGSA,A,3,27,28,08,10,13,19,,,,,,,2.6,1.3,2.3*39 if(/^\$GPGSA,([^,]*),([^,]*),(.*),([^,]*),([^,]*),([^,]*)$/){ # if($1 eq "A"){ print "Automatic"; } # elsif($1 eq "M"){ print "Manual"; } # else { print "Unknown"; } # print " mode "; # # if($2 eq "1") { print "no"; } # elsif($2 eq "2") { print "2D"; } # elsif($2 eq "3") { print "3D"; } # else { print "unknown"; } # print " lock on SVs $3 with PDOP = $4 HDOP = $5 VDOP = $6\n"; } # TODO: this is skipping message three, as there aren't a full set of SVs in it elsif(/^\$GPGSV,([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*)(.*)$/){ # print "Message $2 of $1: $3 SVs in view\n"; # print " $4 SV PRN $5 deg elevation $6 deg azimuth from true north $7 signal to noise ratio\n"; # print " $8 SV PRN $9 deg elevation $10 deg azimuth from true north $11 signal to noise ratio\n"; # print " $12 SV PRN $13 deg elevation $14 deg azimuth from true north $15 signal to noise ratio\n"; } elsif(/^\$GPRMC,([0-9][0-9])([0-9][0-9])([0-9][0-9])(\.[0-9]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([0-9][0-9])([0-9][0-9])([0-9][0-9]),([^,]*),([^,]*)(.*)$/){ print "RMC $1:$2:$3$4 $12/$13/$14 UTC $6 $7 $8 $9 at $10 knots (".($10 * 1.85200)." kmh) heading $11 true\n"; } elsif(/^\$GPGGA,([0-9][0-9])([0-9][0-9])([0-9][0-9])(\.[0-9]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*)(.*)$/){ print "GGA $1:$2:$3$4 UTC $5 $6 $7 $8 "; if($9 eq "0") { print "invalid"; } elsif($9 eq "1") { print "gps"; } elsif($9 eq "2") { print "differential gps"; } else { print "unknown"; } print " fix to $10 SVs with $11 horizontal dilution altitude $12 $13\n"; } elsif(/^\$GPGSV.*$/){ } else{ print " SKIPPED: $_\n"; } }