NAME
GPS::gpsd - Provides a perl interface to the gpsd daemon.
SYNOPSIS
use GPS::gpsd;
$gps=new GPS::gpsd();
my $point=$gps->get();
print $point->lat, " ", $point->lon, "\n";
or
use GPS::gpsd;
$gps=new GPS::gpsd();
$gps->subscribe();
DESCRIPTION
GPS::gpsd provides a perl interface to gpsd daemon. gpsd is an open source gps deamon from http://gpsd.berlios.de/.
For example the method get() returns a hash reference like
{S=>[?|0|1|2],
P=>[lat,lon]}
Fortunately, there are various methods that hide this hash from the user.
METHODS
- new
-
Returns a new gps object.
- subscribe(handler=>\&sub, config=>{})
-
Subscribes subroutine to call when a valid fix is obtained. When the GPS receiver has a good fix this subroutine will be called every second. The return (in v0.5 must be a ref) from this sub will be sent back as the first argument to the subroutine on the next call.
- get
-
Returns a current point object regardless if there is a fix or not. Application should test if $point->fix is true.
- getsatellitelist
-
Returns a list of satellite objects. (maps to gpsd Y command)
- port
-
Get or set the current gpsd TCP port.
- host
-
Get or set the current gpsd host.
- time(p1, p2)
-
Returns the time difference between two points in seconds.
- distance(p1, p2)
-
Returns the distance difference between two points in meters. (plainer calculation)
- track(p1, time)
-
Returns a point object at the predicted location of p1 in time seconds. (plainer calculation based on speed and heading)
- baud
-
Returns the baud rate of the connect GPS receiver. (maps to gpsd B command first data element)
- rate
-
Returns the sampling rate of the GPS receiver. (maps to gpsd C command first data element)
- device
-
Returns the GPS device name. (maps to gpsd F command first data element)
- identification (aka id)
-
Returns a text string identifying the GPS. (maps to gpsd I command first data element)
- protocol
-
Returns the gpsd protocol revision number. (maps to gpsd L command first data element)
- daemon
-
Returns the gpsd daemon version. (maps to gpsd L command second data element)
- commands
-
Returns a string of accepted request letters. (maps to gpsd L command third data element)
GETTING STARTED
KNOWN LIMITATIONS
BUGS
No known bugs.
EXAMPLES
#!/usr/bin/perl
use strict;
use lib './';
use GPS::gpsd;
my $gps=GPS::gpsd->new();
my $data=$gps->get();
my %fix=('?'=>"Error", 0=>"No Fix", 1=>"Fix", 2=>"DGPS-Corrected Fix");
print "gpsd.pm Version:", $gps->VERSION, "\n";
print "gpsd Version:", $data->{'L'}->[1], "\n";
print "Fix:", $data->{'S'}->[0], "=", $fix{$data->{'S'}->[0]}, "\n";
print "Lat:", $data->{'P'}->[0], " Lon:", $data->{'P'}->[1], "\n";
print "Host:", $gps->host, " Port:", $gps->port, "\n";
$gps->subscribe(handler=>\&gps_handler);
sub gps_handler {
my $point=shift();
print join " ", "Fix", $point->{'S'}->[0], $point->{'P'}->[0], $point->{'P'}->[1], "\n";
return $point
}
AUTHOR
Michael R. Davis, qw/gpsd michaelrdavis com/
SEE ALSO
gpsd http tracker http://twiki.davisnetworks.com/bin/view/Main/GpsApplications
gpsd home http://gpsd.berlios.de/