#!/usr/bin/perl -w # Looks at the last available record in gps_raw. # Parses out the $GPRMC sentence. # Uses the gprmc() suproutine to deliver the contents of the sentence. # Prints out results. # # Call: perl gpsgetraw # # Output: <<$dtgps,$lat,$lon,$sog,$cog>> # gps dt m/s degT # use lib $ENV{MYLIB}; use perltools::MRutilities; use perltools::MRtime; my ($str); my @w; my $missing=0; $str=`LastDataRecord gps_raw`; #$str='14 2017 07 13 18 21 49 $GPRMC,182149,V,4738.9764,N,12218.7869,W,,,130717,016.4,E*78'; #$str='14 2017 07 13 18 21 49 $GPRMC,040302.663,A,3939.7,N,10506.6,W,0.27,358.86,200804,018.1,E*7C'; chomp($str); if($str =~ /\$GPRMC/){ $ir = index($str,"GPRMC"); if($ir>10){ my $i1 = index($str,"\$"); my $i2 = index($str,"\*"); $str1=substr($str,$i1,$i2-$i1+3); @x=gprmc($str1,$missing); #$ii=0;foreach(@x){print"$ii, $_\n";$ii++} printf"%d,%.6f,%.6f,%.1f,%.0f,%.1f",$x[0],$x[1],$x[2],$x[3],$x[4],$x[5]; exit 0; } } print"$missing, $missing, $missing, $missing, $missing, $missing"; exit -1;