Net::GPSD(3)

๐Ÿ“ฆ
version 0.39 ยท 2 versions
, in fedora 43

๐Ÿ’– Net::GPSD ๐Ÿ’–

okay bestie, so this is Net::GPSD โ€” a Perl module from the User Contributed Perl Documentation collection. It gives you an object-oriented client interface to the gpsd server daemon. yes you read that right, we're talking to a GPS daemon and it's lowkey iconic. ๐Ÿ›ฐ๏ธโœจ


๐ŸŒธ NAME ๐ŸŒธ

Net::GPSD โ€” provides an object client interface to the gpsd server daemon. periodt.


โœจ SYNOPSIS โœจ

first way, the "gimme one point" way:

 use Net::GPSD;
 $obj=Net::GPSD->new;
 my $point=$obj->get;
 print $point->latlon. "\n";

orrr the "just keep listening forever" way:

 use Net::GPSD;
 $obj=Net::GPSD->new;
 $obj->subscribe();

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

โš ๏ธ not me about to deliver bad news: this package supports the older version 2 protocol. It works for gpsd versions less than 3.00. BUT โ€” for all versions of the gpsd deamon greater than 2.90 you should use the version 3 protocol supported by Net::GPSD3. yes it's giving "please migrate, I'm begging". ๐Ÿ’€

okay so, Net::GPSD provides an object client interface to the gpsd server daemon. gpsd is an open source GPS deamon from http://gpsd.berlios.de/.

for example, the get method returns a blessed hash reference like

{S=>[?|0|1|2],
 P=>[lat,lon]}

and honestly? looking at that raw hash is not the vibe. fortunately, there are various methods that hide this hash from the user. you never have to look at it. we love a protective layer. ๐Ÿซถ


๐ŸŽ€ CONSTRUCTOR ๐ŸŽ€

new

Returns a new Net::GPSD object. brand new, fresh out the box, main character energy. ๐Ÿ‘‘

 my $obj=Net::GPSD->new(host=>"localhost", port=>"2947");

๐Ÿ’… METHODS ๐Ÿ’…

initialize

(that's it. that's the entry. no description given, she's mysterious like that. ๐Ÿ™ˆ)

get

Returns a current point object regardless if there is a fix or not. so basically don't trust it blindly โ€” applications should test if $point->fix is true. do the vibe check, bestie. ๐Ÿ”

 my $point=$obj->get();

subscribe

The subscribe method listens to gpsd server in watcher (W command) mode and calls the handler for each point received. and here's the cute part: the return for the handler will be sent back as the first argument to the handler on the next call. it remembers. it's sentimental. ๐Ÿ˜ญ

 $obj->subscribe();
 $obj->subscribe(handler=>\&gpsd_handler, config=>$config);

default_point_handler

(no description, no drama, just vibes. โœจ)

default_satellitelist_handler

(also just sitting there being iconic. ๐ŸŒˆ)

getsatellitelist

Returns a list of Net::GPSD::Satellite objects. (maps to gpsd Y command) ๐Ÿ›ฐ๏ธ

 my @list=$obj->getsatellitelist;
 my $list=$obj->getsatellitelist;

retrieve

(no notes, she's lowkey.)

open

(no notes either. quiet queen. ๐Ÿคซ)

parse

(also no notes. we respect the mystery.)

host

Sets or returns the current gpsd host.

 my $host=$obj->host;

port

Sets or returns the current gpsd TCP port.

 my $port=$obj->port;

baud

Returns the baud rate of the connect GPS receiver. (maps to gpsd B command first data element)

 my $baud=$obj->baud;

rate

Returns the sampling rate of the GPS receiver. (maps to gpsd C command first data element)

 my $rate=$obj->rate;

device

Returns the GPS device name. (maps to gpsd F command first data element)

 my $device=$obj->device;

identification (aka id)

Returns a text string identifying the GPS. (maps to gpsd I command first data element) โ€” two names, one icon. ๐Ÿ’…

 my $identification=$obj->identification;
 my $identification=$obj->id;

id

(yes, same as above. she's an alias, she's booked and busy. ๐ŸŽ€)

protocol

Returns the GPSD protocol revision number. (maps to gpsd L command first data element)

 my $protocol=$obj->protocol;

daemon

Returns the gpsd daemon version. (maps to gpsd L command second data element)

 my $daemon=$obj->daemon;

commands

Returns a string of accepted command letters. (maps to gpsd L command third data element)

 my $commands=$obj->commands;

๐Ÿ”ฅ FUNCTIONS ๐Ÿ”ฅ

time

Returns the time difference between two point objects in seconds.

 my $seconds=$obj->time($p1, $p2);

distance

Returns the distance difference between two point objects in meters. (simple calculation)

 my $meters=$obj->distance($p1, $p2);

track

Returns a point object at the predicted location in time seconds assuming constant velocity. (Geo::Forward calculation) โ€” future sight but make it math. ๐Ÿ”ฎ

 my $point=$obj->track($p1, $seconds);

q2u

(no description given. she simply exists. โœจ)


๐ŸŒˆ GETTING STARTED ๐ŸŒˆ

Try the examples in the bin folder. Most every method has a default which is most likely what you will want. defaults are the bestie that already knows your order. ๐Ÿ“


โญ LIMITATIONS โญ

The distance function is Geo::Inverse.

The track function uses Geo::Forward.

All units are degrees, meters, seconds. write that down. ๐Ÿ“


๐Ÿ’€ BUGS ๐Ÿ’€

Email the author and log on RT.


๐ŸŒธ EXAMPLES ๐ŸŒธ

(empty. a blank canvas. an artistic choice. ๐ŸŽ€)


๐Ÿซถ SUPPORT ๐Ÿซถ

DavisNetworks.com supports all Perl applications including this package. they got us fr fr. ๐Ÿ’–


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Michael R. Davis, qw/gpsd michaelrdavis com/


๐ŸŽ€ LICENSE ๐ŸŽ€

Copyright (c) 2006 Michael R. Davis (mrdvt92)

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


๐Ÿงš SEE ALSO ๐Ÿงš

Geo::Inverse, Geo::Forward


okay that's the whole page bestie!! ๐Ÿ’œ this was documented by perl v5.42.0 and dated 2025-07-25 โ€” go forth and talk to your GPS daemon responsibly, mwah ๐Ÿ’‹โœจ

๐Ÿ“ฆ where this page comes from