1NMEA(3) User Contributed Perl Documentation NMEA(3)
2
3
4
6 GPS::NMEA - Perl interface to GPS equipment using the NMEA Protocol
7
9 use GPS::NMEA;
10 $gps = new GPS::NMEA( 'Port' => '/dev/ttyS0',
11 'Baud' => 9600,
12 );
13
15 GPS::NMEA allows the connection and use of of a GPS receiver in perl
16 scripts.
17
18 Note that latitudes and longitudes are in DMM format.
19
24 Get the position periodically:
25
26 #!/usr/bin/perl
27 use GPS::NMEA;
28
29 my $gps = GPS::NMEA->new(Port => '/dev/cuaa0', # or COM5: or /dev/ttyS0
30 Baud => 4800);
31 while(1) {
32 my($ns,$lat,$ew,$lon) = $gps->get_position;
33 print "($ns,$lat,$ew,$lon)\n";
34 }
35
36 Get the internal NMEA dump:
37
38 #!/usr/bin/perl
39 use GPS::NMEA;
40 use Data::Dumper;
41
42 my $gps = GPS::NMEA->new(Port => '/dev/cuaa0', # or COM5: or /dev/ttyS0
43 Baud => 4800);
44 while(1) {
45 $gps->parse;
46
47 # Dump internal NMEA data:
48 $gps->nmea_data_dump;
49
50 # Alternative to look at the internal NMEA data:
51 require Data::Dumper;
52 print Data::Dumper->new([$gps->{NMEADATA}],[])->Indent(1)->Useqq(1)->Dump;
53 }
54 __END__
55
57 Joao Pedro B Gonçalves , joaop@iscsp.utl.pt
58
61 Hey! The above document had some coding errors, which are explained
62 below:
63
64 Around line 159:
65 You forgot a '=back' before '=head1'
66
67 Around line 204:
68 Non-ASCII character seen before =encoding in 'Gonçalves'. Assuming
69 CP1252
70
71
72
73perl v5.38.0 2023-07-20 NMEA(3)