| 1 | # | ||||||||||||||||||
| 2 | # Written by Travis Kent Beste | ||||||||||||||||||
| 3 | # Fri Aug 6 22:59:56 CDT 2010 | ||||||||||||||||||
| 4 | |||||||||||||||||||
| 5 | package BT368i::NMEA::GP::GGA; | ||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 8 | 1 | ▶ | use vars qw( ); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 9 | |||||||||||||||||||
| 10 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 11 | |||||||||||||||||||
| 12 | 1 | our @ISA = qw( ); | |||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | 1 | our $VERSION = sprintf("%d.%02d", q$Revision: 1.00 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||
| 15 | |||||||||||||||||||
| 16 | #----------------------------------------# | ||||||||||||||||||
| 17 | # | ||||||||||||||||||
| 18 | #----------------------------------------# | ||||||||||||||||||
| 19 | 0 | ▶ | sub new { | ||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 20 | 0 | my $class = shift; | |||||||||||||||||
| 21 | 0 | my %args = shift; | |||||||||||||||||
| 22 | |||||||||||||||||||
| 23 | 0 | my %fields = ( | |||||||||||||||||
| 24 | log_fh => '', | ||||||||||||||||||
| 25 | log_filename => '', | ||||||||||||||||||
| 26 | |||||||||||||||||||
| 27 | utc_time => '', | ||||||||||||||||||
| 28 | latitude => '', | ||||||||||||||||||
| 29 | latitude_hemisphere => '', | ||||||||||||||||||
| 30 | longitude => '', | ||||||||||||||||||
| 31 | longitude_hemisphere => '', | ||||||||||||||||||
| 32 | fix_type => '', | ||||||||||||||||||
| 33 | satilites_in_use => '', | ||||||||||||||||||
| 34 | horizontal_dilution => '', | ||||||||||||||||||
| 35 | antenna_height => '', | ||||||||||||||||||
| 36 | geoidal_height => '', | ||||||||||||||||||
| 37 | dgps_data_age => '', | ||||||||||||||||||
| 38 | dgps_reference_station_id => '', | ||||||||||||||||||
| 39 | ); | ||||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | 0 | my $self = { | |||||||||||||||||
| 42 | %fields, | ||||||||||||||||||
| 43 | }; | ||||||||||||||||||
| 44 | 0 | bless $self, $class; | |||||||||||||||||
| 45 | |||||||||||||||||||
| 46 | 0 | return $self; | |||||||||||||||||
| 47 | } | ||||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | #----------------------------------------# | ||||||||||||||||||
| 50 | # | ||||||||||||||||||
| 51 | #----------------------------------------# | ||||||||||||||||||
| 52 | 0 | ▶ | sub print { | ||||||||||||||||
|
Subroutine
print: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||
| 53 | 0 | my $self = shift; | |||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | 0 | print "utc_time : " . $self->{utc_time} . "\n"; | |||||||||||||||||
| 56 | 0 | print "latitude : " . $self->{latitude} . "\n"; | |||||||||||||||||
| 57 | 0 | ▶ | if ($self->{latitude_hemisphere} eq 'N') { | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 58 | 0 | print "hemisphere : NORTH\n"; | |||||||||||||||||
| 59 | } elsif ($self->{latitude_hemisphere} eq 'N') { | ||||||||||||||||||
| 60 | 0 | print "hemisphere : SOUTH\n"; | |||||||||||||||||
| 61 | } | ||||||||||||||||||
| 62 | 0 | print "longitude : " . $self->{longitude} . "\n"; | |||||||||||||||||
| 63 | 0 | ▶ | if ($self->{longitude_hemisphere} eq 'E') { | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 64 | 0 | print "hemisphere : EAST\n"; | |||||||||||||||||
| 65 | } elsif ($self->{longitude_hemisphere} eq 'W') { | ||||||||||||||||||
| 66 | 0 | print "hemisphere : WEST\n"; | |||||||||||||||||
| 67 | } | ||||||||||||||||||
| 68 | 0 | ▶ | if ($self->{fix_type} == 0) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 69 | 0 | print "fix_type : no fix\n"; | |||||||||||||||||
| 70 | } elsif ($self->{fix_type} == 1) { | ||||||||||||||||||
| 71 | 0 | print "fix_type : non-DGPS\n"; | |||||||||||||||||
| 72 | } elsif ($self->{fix_type} == 2) { | ||||||||||||||||||
| 73 | 0 | print "fix_type : DGPS\n"; | |||||||||||||||||
| 74 | } | ||||||||||||||||||
| 75 | 0 | print "satilites in use : " . $self->{satilites_in_use} . "\n"; | |||||||||||||||||
| 76 | 0 | print "horizontal dilution of prec. : " . $self->{horizontal_dilution} . "\n"; | |||||||||||||||||
| 77 | 0 | print "height above/below mean sea : " . $self->{antenna_height} . " meters\n"; | |||||||||||||||||
| 78 | 0 | print "height above/below mean sea : " . $self->{geoidal_height} . " meters\n"; | |||||||||||||||||
| 79 | 0 | print "DGPS data age : "; | |||||||||||||||||
| 80 | 0 | ▶ | if ($self->{dgps_data_age} ne '') { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 81 | 0 | print $self->{dgps_data_age} . " seconds\n"; | |||||||||||||||||
| 82 | } else { | ||||||||||||||||||
| 83 | 0 | print "\n"; | |||||||||||||||||
| 84 | } | ||||||||||||||||||
| 85 | 0 | print "DGPS reference station id : " . $self->{dgps_reference_station_id} . "\n"; | |||||||||||||||||
| 86 | } | ||||||||||||||||||
| 87 | |||||||||||||||||||
| 88 | #----------------------------------------# | ||||||||||||||||||
| 89 | # | ||||||||||||||||||
| 90 | #----------------------------------------# | ||||||||||||||||||
| 91 | 0 | ▶ | sub parse { | ||||||||||||||||
|
Subroutine
parse: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||
| 92 | 0 | my $self = shift; | |||||||||||||||||
| 93 | 0 | my $data = shift; | |||||||||||||||||
| 94 | |||||||||||||||||||
| 95 | # if we're logging, save data to filehandle | ||||||||||||||||||
| 96 | 0 | ▶ | if ($self->{log_fh}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 97 | 0 | print { $self->{log_fh} } $data . "\n"; | |||||||||||||||||
| 98 | } | ||||||||||||||||||
| 99 | |||||||||||||||||||
| 100 | 0 | $data =~ s/\*..$//; # remove the last three bytes | |||||||||||||||||
| 101 | 0 | my @args = split(/,/, $data); | |||||||||||||||||
| 102 | |||||||||||||||||||
| 103 | # 1) UTC time of position fix, hhmmss format | ||||||||||||||||||
| 104 | 0 | my @utc_time = split(//, $args[1]); | |||||||||||||||||
| 105 | 0 | my $hh = $utc_time[0]; $hh .= $utc_time[1]; | |||||||||||||||||
| 106 | 0 | my $mm = $utc_time[2]; $mm .= $utc_time[3]; | |||||||||||||||||
| 107 | 0 | my $ss = $utc_time[4]; $ss .= $utc_time[5]; | |||||||||||||||||
| 108 | 0 | my $ms = $utc_time[7]; $ms .= $utc_time[8]; $ms .= $utc_time[1]; | |||||||||||||||||
| 109 | 0 | $self->{utc_time} = $hh . ':' . $mm . ':' . $ss . '.' . $ms; | |||||||||||||||||
| 110 | |||||||||||||||||||
| 111 | # 2) Latitude, ddmm.mmmm format (leading zeroes will be transmitted) | ||||||||||||||||||
| 112 | 0 | $self->{latitude} = $args[2]; | |||||||||||||||||
| 113 | |||||||||||||||||||
| 114 | # 3) Latitude hemisphere, N or S | ||||||||||||||||||
| 115 | 0 | $self->{latitude_hemisphere} = $args[3]; | |||||||||||||||||
| 116 | |||||||||||||||||||
| 117 | # 4) Longitude, dddmm.mmmm format (leading zeros will be transmitted) | ||||||||||||||||||
| 118 | 0 | $self->{longitude} = $args[4]; | |||||||||||||||||
| 119 | |||||||||||||||||||
| 120 | # 5) Longitude hemisphere, E or W | ||||||||||||||||||
| 121 | 0 | $self->{longitude_hemisphere} = $args[5]; | |||||||||||||||||
| 122 | |||||||||||||||||||
| 123 | # 6) GPS quality indication, 0=no fix, 1=non-DGPS fix, 2=DGPS fix | ||||||||||||||||||
| 124 | 0 | $self->{fix_type} = $args[6]; | |||||||||||||||||
| 125 | |||||||||||||||||||
| 126 | # 7) Number of sats in use, 00 to 12 | ||||||||||||||||||
| 127 | 0 | $self->{satilites_in_use} = $args[7]; | |||||||||||||||||
| 128 | |||||||||||||||||||
| 129 | # 8) Horizontal Dilution of Precision 1.0 to 99.9 | ||||||||||||||||||
| 130 | 0 | $self->{horizontal_dilution} = $args[8]; | |||||||||||||||||
| 131 | |||||||||||||||||||
| 132 | # 9) Antenna height above/below mean sea level, -9999.9 to 99999.9 meters | ||||||||||||||||||
| 133 | 0 | $self->{antenna_height} = $args[9]; | |||||||||||||||||
| 134 | |||||||||||||||||||
| 135 | # 10) Geoidal height, -999.9 to 9999.9 meters | ||||||||||||||||||
| 136 | 0 | $self->{geoidal_height} = $args[11]; | |||||||||||||||||
| 137 | |||||||||||||||||||
| 138 | # 11) DGPS data age, number of seconds since last valid RTCM transmission (null if non-DGPS) | ||||||||||||||||||
| 139 | 0 | $self->{dgps_data_age} = $args[13]; | |||||||||||||||||
| 140 | |||||||||||||||||||
| 141 | # 12) DGPS reference station ID, 0000 to 1023 (leading zeros will be sent, null if non-DGPS) | ||||||||||||||||||
| 142 | 0 | $self->{dgps_reference_sation_id} = $args[14]; | |||||||||||||||||
| 143 | } | ||||||||||||||||||
| 144 | |||||||||||||||||||
| 145 | 1 | 1; | |||||||||||||||||
| 146 | |||||||||||||||||||
| 147 | __END__ | ||||||||||||||||||