Net-GPSD3-0.19/0000755000076400007640000000000011677244637012370 5ustar mdavismdavisNet-GPSD3-0.19/README0000644000076400007640000000033311326333640013227 0ustar mdavismdavisTo install $> cpan2rpm Net::GPSD3 $> sudo rpm -Uhv perl-Net-GPSD3-0.0X-1.noarch.rpm OR $> perl Makefile.PL $> make $> make test #> make install If you are on a windows box you should use 'nmake' rather than 'make'. Net-GPSD3-0.19/Todo0000644000076400007640000000006611326333640013202 0ustar mdavismdavisTODO list for Perl module Net::GPSD3 - Nothing yet Net-GPSD3-0.19/META.yml0000664000076400007640000000127011677244637013643 0ustar mdavismdavis--- #YAML:1.0 name: Net-GPSD3 version: 0.19 abstract: Interface to the gpsd server daemon protocol versions 3 (JSON). license: ~ author: - Michael R. Davis (domain=>michaelrdavis,tld=>com,account=>perl) generated_by: ExtUtils::MakeMaker version 6.42 distribution_type: module requires: DateTime: 0 DateTime::Format::W3CDTF: 0.06 GPS::Point: 0.1 IO::Socket::INET6: 0 JSON::XS: 0 Test::Simple: 0.44 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.3.html version: 1.3 Net-GPSD3-0.19/Makefile.PL0000644000076400007640000000122011640222353014312 0ustar mdavismdavisuse ExtUtils::MakeMaker; WriteMakefile( NAME => 'Net::GPSD3', VERSION_FROM => 'lib/Net/GPSD3.pm', AUTHOR => 'Michael R. Davis (domain=>michaelrdavis,tld=>com,account=>perl)', ABSTRACT_FROM=> 'lib/Net/GPSD3.pm', PREREQ_PM => { 'Test::Simple' => 0.44, 'GPS::Point' => 0.10, 'JSON::XS' => 0, 'IO::Socket::INET6' => 0, 'DateTime' => 0, 'DateTime::Format::W3CDTF' => 0.06, #factional seconds }, ); Net-GPSD3-0.19/scripts/0000755000076400007640000000000011677244637014057 5ustar mdavismdavisNet-GPSD3-0.19/scripts/perl-Net-GPSD3-poll.pl0000644000076400007640000000221611546525570017656 0ustar mdavismdavis#!/usr/bin/perl use strict; use warnings; use Net::GPSD3; use Data::Dumper qw{Dumper}; =head1 NAME perl-Net-GPSD3-poll.pl - Net::GPSD3 Poll Example =cut my $host=shift || undef; my $port=shift || undef; my $debug=shift || 0; my $gpsd=Net::GPSD3->new(host=>$host, port=>$port); #default host port as undef my $poll=$gpsd->poll; printf "Net::GPSD3: %s\n", $poll->parent->VERSION; printf "GPSD Release: %s\n", $poll->parent->cache->VERSION->release; printf "Protocol: %s\n", $poll->parent->cache->VERSION->protocol; printf "Sats Reported: %s\n", $poll->sky->reported; printf "Sats Used: %s\n", $poll->sky->used; printf "Timestamp: %s\n", $poll->tpv->timestamp; printf "Latitude: %s\n", $poll->tpv->lat; printf "Longitude: %s\n", $poll->tpv->lon; printf "Altitude: %s\n", $poll->tpv->alt; print Dumper($gpsd->poll) if $debug; =head1 Example Output Net::GPSD3: 0.15 GPSD Release: 2.96 Protocol: 3.4 Sats Reported: 13 Sats Used: 9 Timestamp: 2011-04-05T05:35:08.00Z Latitude: 37.371420138 Longitude: -122.01518436 Altitude: 28.974 =cut Net-GPSD3-0.19/scripts/perl-Net-GPSD3-Handler.pl0000644000076400007640000000504511677244060020265 0ustar mdavismdavis#!/usr/bin/perl use strict; use warnings; use Net::GPSD3; use Data::Dumper qw{Dumper}; $|=1; my $host = shift || undef; #you can pass zero or "" my $port = shift || undef; #you can pass zero or "" our $debug = shift || 0; =head1 NAME perl-Net-GPSD3-Handler.pl - Net::GPSD3 Watcher with Custom Handler =cut my $gpsd=Net::GPSD3->new(host=>$host, port=>$port); #default host port is undef $gpsd->addHandler(\&tpv); $gpsd->addHandler(\&sky); $gpsd->watch; sub tpv { my $tpv=shift; return unless $tpv->class eq "TPV"; print Dumper($tpv) if $debug; printf "%s: %s, %s, %s\n", $tpv->timestamp, $tpv->lat, $tpv->lon, $tpv->alt; } sub sky { my $sky=shift; return unless $sky->class eq "SKY"; print Dumper($sky) if $debug; printf "Satellites: %s\n", join(", ", map {$_->prn} $sky->Satellites); } =head1 Example Output 2011-04-08T05:13:10.00Z: 37.37143214, -122.015171692, 26.72 2011-04-08T05:13:11.00Z: 37.37143214, -122.015171692, 26.72 2011-04-08T05:13:12.00Z: 37.37143214, -122.015171692, 26.72 2011-04-08T05:13:13.00Z: 37.37143214, -122.015171692, 26.72 2011-04-08T05:13:14.00Z: 37.37143214, -122.015171692, 26.72 2011-04-08T05:13:15.00Z: 37.37143214, -122.015171692, 26.72 2011-04-08T05:13:16.00Z: 37.37143214, -122.015171692, 26.72 2011-04-08T05:13:17.00Z: 37.37143214, -122.015171692, 26.72 2011-04-08T05:13:18.00Z: 37.37143214, -122.015171692, 26.72 Satellites: 27, 15, 8, 17, 28, 7, 26, 24, 9, 138, 135 2011-04-08T05:13:19.00Z: 37.37143214, -122.015171692, 26.72 2011-04-08T05:13:20.00Z: 37.37143214, -122.015171692, 26.72 2011-04-08T05:13:21.00Z: 37.37143214, -122.015171692, 26.72 2011-04-08T05:13:22.00Z: 37.371432094, -122.015171632, 26.726 2011-04-08T05:13:23.00Z: 37.371432094, -122.015171632, 26.726 2011-04-08T05:13:24.00Z: 37.371432094, -122.015171632, 26.726 2011-04-08T05:13:25.00Z: 37.371432094, -122.015171632, 26.726 2011-04-08T05:13:26.00Z: 37.371432094, -122.015171632, 26.726 2011-04-08T05:13:27.00Z: 37.371432094, -122.015171632, 26.726 2011-04-08T05:13:28.00Z: 37.371432094, -122.015171632, 26.726 Satellites: 27, 15, 8, 17, 28, 7, 26, 24, 9, 138, 135 2011-04-08T05:13:29.00Z: 37.371432094, -122.015171632, 26.726 2011-04-08T05:13:30.00Z: 37.371432094, -122.015171632, 26.726 2011-04-08T05:13:31.00Z: 37.371432094, -122.015171632, 26.726 2011-04-08T05:13:32.00Z: 37.371432094, -122.015171632, 26.726 2011-04-08T05:13:33.00Z: 37.371432094, -122.015171632, 26.726 2011-04-08T05:13:34.00Z: 37.371432094, -122.015171632, 26.726 =cut Net-GPSD3-0.19/scripts/perl-Net-GPSD3-Example.pl0000644000076400007640000000255211546525442020304 0ustar mdavismdavis#!/usr/bin/perl use strict; use warnings; $|=1; =head1 NAME perl-Net-GPSD3-Example.pl - Net::GPSD3 Watcher Example =cut use Net::GPSD3; my $host=shift || undef; my $port=shift || undef; my $gpsd=Net::GPSD3->new(host=>$host, port=>$port); #default host port as undef $gpsd->watch; #default handler =head1 EXAMPLE OUTPUT 2011-04-05T05:39:05: VERSION, GPSD: 2.96~dev (2011-03-17T02:51:23), Net::GPSD3: 0.15 2011-04-05T05:39:05: DEVICES, Devices: /dev/cuaU0 (9600 bps uBlox UBX binary-none) 2011-04-05T05:39:05: WATCH, Enabled: 1 2011-04-05T05:39:05: TPV, Time: 2011-04-05T05:39:05.00Z, Lat: 37.371420332, Lon: -122.015185689, Speed: 0, Heading: 0 2011-04-05T05:39:06: TPV, Time: 2011-04-05T05:39:06.00Z, Lat: 37.371420332, Lon: -122.015185689, Speed: 0, Heading: 0 2011-04-05T05:39:07: TPV, Time: 2011-04-05T05:39:07.00Z, Lat: 37.371420332, Lon: -122.015185689, Speed: 0, Heading: 0 2011-04-05T05:39:08: TPV, Time: 2011-04-05T05:39:08.00Z, Lat: 37.371420332, Lon: -122.015185689, Speed: 0, Heading: 0 2011-04-05T05:39:08: SKY, Satellites: 11, Used: 6, PRNs: 28,24,8,15,26,135 2011-04-05T05:39:09: TPV, Time: 2011-04-05T05:39:09.00Z, Lat: 37.371420332, Lon: -122.015185689, Speed: 0, Heading: 0 2011-04-05T05:39:10: TPV, Time: 2011-04-05T05:39:10.00Z, Lat: 37.371420332, Lon: -122.015185689, Speed: 0, Heading: 0 =cut Net-GPSD3-0.19/perl-Net-GPSD3.spec0000644000076400007640000000423311677244536015550 0ustar mdavismdavisName: perl-Net-GPSD3 Version: 0.19 Release: 2%{?dist} Summary: Interface to the gpsd server daemon protocol versions 3 (JSON) License: BSD Group: Development/Libraries URL: http://search.cpan.org/dist/Net-GPSD3/ Source0: http://www.cpan.org/modules/by-module/Net/Net-GPSD3-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch BuildRequires: perl(ExtUtils::MakeMaker) BuildRequires: perl(Test::Simple) >= 0.44 Requires: perl(DateTime) Requires: perl(DateTime::Format::W3CDTF) >= 0.06 Requires: perl(GPS::Point) >= 0.10 Requires: perl(IO::Socket::INET6) Requires: perl(JSON::XS) Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) %description Net::GPSD3 provides an object client interface to the gpsd server daemon utilizing the version 3 protocol. gpsd is an open source GPS daemon from http://www.catb.org/gpsd/. Support for Version 3 of the protocol (JSON) was added to the daemon in version 2.90. If your daemon is before 2.90 (protocol 2.X), please use the L package. %prep %setup -q -n Net-GPSD3-%{version} %build %{__perl} Makefile.PL INSTALLDIRS=vendor make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make pure_install PERL_INSTALL_ROOT=$RPM_BUILD_ROOT find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} \; find $RPM_BUILD_ROOT -depth -type d -exec rmdir {} 2>/dev/null \; %{_fixperms} $RPM_BUILD_ROOT/* %check make test %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %doc Changes LICENSE perl-Net-GPSD3.spec README Todo %{perl_vendorlib}/* %{_mandir}/man3/* %changelog * Thu Dec 29 2011 Michael R. Davis (mdavis@stopllc.com) 0.19-2 - Merged changes from SVN * Thu Dec 29 2011 Michael R. Davis (mdavis@stopllc.com) 0.19-1 - Updated for version 0.19 * Tue Dec 27 2011 Michael R. Davis (mdavis@stopllc.com) 0.18-2 - Updated GPSD URL in description * Tue Dec 27 2011 Michael R. Davis (mdavis@stopllc.com) 0.18-1 - Updated for version 0.18 * Fri Apr 08 2011 Michael R. Davis (mdavis@stopllc.com) 0.16-1 - Specfile autogenerated by cpanspec 1.78. Net-GPSD3-0.19/Changes0000644000076400007640000000742211677244317013663 0ustar mdavismdavisRevision history for Perl module Net::GPSD3 TODO - Support SUBFRAME objects better - Add Tests for many GPS devices - Add a capability for handlers to turn off watcher mode. - Consolidate code between Net::GPSD3->watch and Net::GPSD::POE->session - Figure out a better way to use the default handlers - Review time vs. datetime - Figure out if we can drop DateTime due to the load time. - Figure out if we can make DateTime a runtime requirement. 0.19 2011-12-29 - Added use strict and use warnings to all tests - RT 73612 - Fixed spec version 0.18_2 2011-09-26 - Updated GPSD URL 0.18 2011-09-26 - Fixed POLL method GPSD API change - RT 73489 ryan from presslab.us - Dropped EXE_FILES section from Makefile.PL - RT 70414 - fschlich at cis.fu-berlin.de - Fixed spelling issues in pod - RT 70410 - fschlich at cis.fu-berlin.de 0.17 2011-04-10 - Moved Net::GPSD3::POE to separate package 0.16 2011-04-08 - Updated perl-Net-GPSD3-Handler.pl to use two handlers - Updated POE interface based on feedback from Rocco Caputo - Switched from inline_states session to object_states session - Added stop and shutdown capabilities - Added POE methods pause and resume 0.15 2011-04-05 - Added POE::Session capability - Added Net::GPSD3::POE->session - Updated tests - Fixed Net::GPSD3->constructor to support inheritance - Added POE script example - Update script documentation 0.14 2011-03-26 - Added Documentation and Examples - Added poll->tpv alias for poll->fix method - Updated support for GST object - Updated perl-Net-GPSD3-poll.pl to show much more data - Updated default handler changed tpv->time to tpv->timestamp 0.13 2011-03-25 - Added poll->fix method - Added poll->sky method - Renamed internal method poll->fixes to _fixes - Renamed internal method poll->skyviews to _skyviews - Updated POLL documentation - Added GST object support 0.12 2011-03-24 - gpsd 2.96 protocol 3.4 support - Do not expect the protocol to stabilize until gpsd 3.00 - Added support for new POLL interface - Added support for SUBFRAME object - Updated objects to support new W3C timestamp format - Added RPM spec file to the distribution - Updated tests for the new protocol 3.4 - Updated Net/GPSD3.pm - Moved defaults into methods - Added object caching in gpsd->cache method - Removed the intersperse capability as redundant with caching - Renamed example scripts - Dropped strftime support (not backwards compatible!) 0.11 2010-01-14 - gpsd protocol 3.3 support - Moved to IO::Socket::INET6 to support both IPv4 and IPv6 0.10 2010-01-01 - Updated GPS::Point minimum required version to 0.10 0.09 2009-11-27 - Added DateTime to handler output 0.08 2009-12-06 - API changed between gpsd versions 2.90dev and 2.90 - Added json=>true to ?WATCH request 0.07 2009-11-22 - Support some changes in the protocol in 2.90dev. 0.06 2009-10-03T5:34:00Z - Satellite->reported property was dropped (now calculated) 0.05 2009-09-28T18:31:00Z - modified SKY->Satellites to reuse parent->constructor code. 0.04 2009-09-26T23:03:00Z - Documentation - Changed satelliteObjects to Satellites (still have satellites) - Changed DeviceObjects to Devices (still have devices) - Added Error trapping and better messages 0.03 2009-09-19T06:48:00Z - Fixed up DEVICE package - Fixed up ERROR package - Refactored a bunch of the code to make testing easier - Added more tests - Added Example 0.02 2009-09-16T00:20:00Z - Documentation - Updated SKY->satellites - Added SKY->satelliteObjects - Updated Makefile.PL -> prereq 0.01 2009-04-14T18:58:54Z - gpsd version 3.1 protocol Net-GPSD3-0.19/t/0000755000076400007640000000000011677244637012633 5ustar mdavismdavisNet-GPSD3-0.19/t/005_Satellite.t0000644000076400007640000000145611677240151015323 0ustar mdavismdavis# -*- perl -*- use strict; use warnings; use Test::More tests => 12; BEGIN { use_ok( 'Net::GPSD3' ); } #Note "class" here is a Net::GPSD3 pseudo class #my $string=q({"class":"Satellite","PRN":15,"el":75,"az":77,"ss":38,"used":true}); my $string='{"PRN":17,"el":76,"az":174,"ss":34,"used":true}'; my $gpsd=Net::GPSD3->new; isa_ok ($gpsd, 'Net::GPSD3'); my $object=$gpsd->constructor(class=>"Satellite", $gpsd->decode($string), string=>$string); isa_ok ($object, 'Net::GPSD3::Return::Satellite'); isa_ok ($object->parent, 'Net::GPSD3'); is($object->string, $string, 'string'); is($object->class, 'Satellite', 'class'); is($object->PRN, '17', 'PRN'); is($object->el, '76', 'el'); is($object->az, '174', 'az'); is($object->ss, '34', 'ss'); ok($object->used, 'used'); isa_ok ($object->used, 'JSON::XS::Boolean'); Net-GPSD3-0.19/t/004_SKY.t0000644000076400007640000000527611677240134014047 0ustar mdavismdavis# -*- perl -*- use strict; use warnings; use Test::More tests => 22; BEGIN { use_ok( 'Net::GPSD3' ); } #my $string=q({"class":"SKY","tag":"GSV","device":"/dev/ttyUSB0","time":1253336487.996,"reported":9,"satellites":[{"PRN":15,"el":75,"az":77,"ss":38,"used":true},{"PRN":21,"el":50,"az":310,"ss":35,"used":true},{"PRN":29,"el":39,"az":219,"ss":0,"used":false},{"PRN":18,"el":32,"az":276,"ss":0,"used":false},{"PRN":5,"el":28,"az":69,"ss":41,"used":true},{"PRN":10,"el":25,"az":69,"ss":40,"used":true},{"PRN":27,"el":22,"az":144,"ss":0,"used":false},{"PRN":9,"el":12,"az":160,"ss":0,"used":false},{"PRN":8,"el":9,"az":39,"ss":41,"used":true}]}); my $string='{ "class":"SKY", "tag":"0x0120", "device":"/dev/cuaU0", "xdop":0.58, "ydop":0.96, "vdop":1.92, "tdop":1.14, "hdop":1.90, "gdop":2.93, "pdop":2.70, "satellites":[ {"PRN":17,"el":76,"az":174,"ss":34,"used":true}, {"PRN":28,"el":57,"az":38,"ss":30,"used":false}, {"PRN":27,"el":22,"az":314,"ss":18,"used":true}, {"PRN":7,"el":15,"az":127,"ss":29,"used":true}, {"PRN":15,"el":31,"az":297,"ss":27,"used":true}, {"PRN":11,"el":18,"az":54,"ss":28,"used":false}, {"PRN":24,"el":18,"az":63,"ss":29,"used":false}, {"PRN":9,"el":4,"az":313,"ss":18,"used":false}, {"PRN":8,"el":45,"az":117,"ss":33,"used":true}, {"PRN":26,"el":49,"az":245,"ss":37,"used":true}, {"PRN":4,"el":5,"az":170,"ss":17,"used":false}, {"PRN":138,"el":44,"az":157,"ss":40,"used":true}]}'; my $gpsd=Net::GPSD3->new; isa_ok ($gpsd, 'Net::GPSD3'); my $object=$gpsd->constructor($gpsd->decode($string), string=>$string); isa_ok ($object, 'Net::GPSD3::Return::SKY'); isa_ok ($object->parent, 'Net::GPSD3'); is($object->class, 'SKY', 'class'); is($object->string, $string, 'string'); is($object->tag, '0x0120', 'tag'); is($object->device, '/dev/cuaU0', 'device'); is($object->reported, '12', 'reported'); is($object->used, '7', 'reported'); my $s; my @s; $s=$object->satellites; isa_ok($s, 'ARRAY', 'satellites 1'); is(scalar(@$s), '12', 'satellites 2'); isa_ok($s->[0], 'HASH', 'satellites 3'); @s=$object->satellites; is(scalar(@s), '12', 'satellites 4'); isa_ok($s[0], 'HASH', 'satellites 5'); $s=$object->Satellites; isa_ok($s, 'ARRAY', 'Satellites 6'); is(scalar(@$s), '12', 'Satellites 7'); isa_ok($s->[0], 'Net::GPSD3::Return::Satellite', 'Satellites 8'); isa_ok ($s->[0]->parent, 'Net::GPSD3'); #Current architecture does not keep order... #is($s->[0]->string, '{"PRN":15,"el":75,"az":77,"ss":38,"used":true}', 'string'); @s=$object->Satellites; is(scalar(@s), '12', 'Satellites 9'); isa_ok($s[0], 'Net::GPSD3::Return::Satellite', 'Satellites 10'); my $satellite=$s->[0]; isa_ok($satellite, 'Net::GPSD3::Return::Satellite', 'Satellites 11'); Net-GPSD3-0.19/t/003_TPV.t0000644000076400007640000000362511677240325014047 0ustar mdavismdavis# -*- perl -*- use strict; use warnings; use Test::More tests => 30; BEGIN { use_ok( 'Net::GPSD3' ); } my $gpsd=Net::GPSD3->new; isa_ok ($gpsd, 'Net::GPSD3'); #my $string=q({"class":"TPV","tag":"RMC","device":"/dev/ttyUSB0","time":1253334480.119,"ept":0.005,"lat":38.949656667,"lon":-77.350946667,"epx":750.000,"epy":750.000,"epv":1150.000,"track":17.0300,"speed":0.211,"mode":3}); my $string='{"class":"TPV","tag":"0x0106","device":"/dev/cuaU0","time":"2011-03-20T06:51:59.12Z","ept":0.005,"lat":37.371427205,"lon":-122.015179890,"alt":25.789,"epx":1.926,"epy":1.808,"epv":6.497,"track":0.0000,"speed":0.000,"climb":0.000,"eps":3.85,"mode":3}'; my $object=$gpsd->constructor($gpsd->decode($string), string=>$string); isa_ok($object, 'Net::GPSD3::Return::TPV'); isa_ok($object->parent, 'Net::GPSD3'); is($object->string, $string, 'string'); is($object->class, 'TPV', 'class'); is($object->tag, "0x0106", "tag"); is($object->device, "/dev/cuaU0", "device"); is($object->time, "1300603919.12", "time"); is($object->timestamp, "2011-03-20T06:51:59.12Z", "time"); isa_ok($object->datetime, "DateTime"); is($object->datetime->iso8601, "2011-03-20T06:51:59", "datetime"); #just to second is($object->datetime->hires_epoch, "1300603919.12", "datetimei epoch"); is($object->ept, "0.005", "ept"); is($object->lat, "37.371427205", "lat"); is($object->lon, "-122.01517989", "lon"); is($object->epx, "1.926", "epx"); is($object->epy, "1.808", "epy"); is($object->epv, "6.497", "epv"); is($object->eps, "3.85", "epv"); is($object->track, "0", "track"); is($object->speed, "0", "speed"); is($object->climb, "0", "climb"); is($object->mode, "3", "mode"); isa_ok ($object->point, 'GPS::Point'); is($object->point->datetime->iso8601, "2011-03-20T06:51:59", "datetime"); is($object->point->lat, "37.371427205", "lat"); is($object->point->lon, "-122.01517989", "lon"); is($object->point->heading, "0", "track"); is($object->point->speed, "0", "speed"); Net-GPSD3-0.19/t/009_POLL_transitional.t0000644000076400007640000000545111677244130016736 0ustar mdavismdavis# -*- perl -*- use Test::More tests => 24; BEGIN { use_ok( 'Net::GPSD3' ); } my $string='{ "class":"POLL", "timestamp":"2011-03-20T04:12:25.64Z", "active":1, "fixes":[ { "class":"TPV", "tag":"0x0130", "device":"/dev/cuaU0", "time":"2011-03-20T04:12:25.00Z", "ept":0.005, "lat":37.371425314, "lon":-122.015172578, "alt":25.817, "epx":2.436, "epy":2.863, "epv":11.040, "track":0.0000, "speed":0.000, "climb":0.000, "eps":5.73, "mode":3 } ], "gst":[{ "class":"GST","tag":"0x0130","device":"/dev/cuaU0","time":"1970-01-01T00:00:00.00Z", "rms":0.000,"major":0.000,"minor":0.000,"orient":0.000,"lat":0.000,"lon":0.000,"alt":0.000 }], "skyviews":[ { "class":"SKY", "tag":"0x0130", "device":"/dev/cuaU0", "xdop":0.65, "ydop":0.76, "vdop":1.30, "tdop":0.80, "hdop":1.00, "gdop":1.83, "pdop":1.64, "satellites":[ {"PRN":28,"el":59,"az":248,"ss":24,"used":true}, {"PRN":13,"el":32,"az":150,"ss":30,"used":true}, {"PRN":7,"el":60,"az":59,"ss":28,"used":true}, {"PRN":10,"el":19,"az":227,"ss":22,"used":false}, {"PRN":19,"el":29,"az":57,"ss":22,"used":true}, {"PRN":5,"el":21,"az":276,"ss":36,"used":true}, {"PRN":3,"el":6,"az":38,"ss":15,"used":false}, {"PRN":8,"el":62,"az":342,"ss":30,"used":true}, {"PRN":26,"el":22,"az":318,"ss":31,"used":false}, {"PRN":11,"el":10,"az":114,"ss":21,"used":false}, {"PRN":138,"el":44,"az":157,"ss":41,"used":true}, {"PRN":17,"el":10,"az":187,"ss":29,"used":false} ]}]}'; my $gpsd=Net::GPSD3->new; isa_ok ($gpsd, 'Net::GPSD3'); my $object=$gpsd->constructor($gpsd->decode($string), string=>$string); isa_ok ($object, 'Net::GPSD3::Return::POLL'); isa_ok ($object->parent, 'Net::GPSD3'); is($object->string, $string, 'string'); is($object->class, 'POLL', 'class'); is($object->active, "1", "active"); is($object->time, "1300594345.64", "time"); is($object->timestamp, "2011-03-20T04:12:25.64Z", "timestamp"); isa_ok($object->_skyviews, "ARRAY", "skyviews"); is(scalar(@{$object->_skyviews}), 1, "sizeof"); isa_ok($object->_skyviews->[0], "HASH"); isa_ok($object->_fixes, "ARRAY", "fixes"); is(scalar(@{$object->_fixes}), 1, "sizeof"); isa_ok($object->_fixes->[0], "HASH"); isa_ok($object->Skyviews, "ARRAY", "Skyviews"); is(scalar(@{$object->Skyviews}), 1, "sizeof"); isa_ok($object->Skyviews->[0], "Net::GPSD3::Return::SKY"); isa_ok($object->Skyviews->[0]->Satellites, "ARRAY"); isa_ok($object->Fixes, "ARRAY", "Fixes"); is(scalar(@{$object->Fixes}), 1, "sizeof"); isa_ok($object->Fixes->[0], "Net::GPSD3::Return::TPV"); isa_ok($object->sky, "Net::GPSD3::Return::SKY"); isa_ok($object->fix, "Net::GPSD3::Return::TPV"); Net-GPSD3-0.19/t/008_VERSION.t0000644000076400007640000000172611677240206014526 0ustar mdavismdavis# -*- perl -*- use strict; use warnings; use Test::More tests => 13; BEGIN { use_ok( 'Net::GPSD3' ); } #my $string=q({"class":"VERSION","release":"2.40dev","rev":"$Id: gpsd.c 5957 2009-08-23 15:45:54Z esr $","proto_major":3,"proto_minor":1}); my $string='{"class":"VERSION","release":"2.96~dev","rev":"2011-03-17T02:51:23","proto_major":3,"proto_minor":4}'; my $gpsd=Net::GPSD3->new; isa_ok ($gpsd, 'Net::GPSD3'); my $object=$gpsd->constructor($gpsd->decode($string), string=>$string); isa_ok ($object, 'Net::GPSD3::Return::VERSION'); isa_ok ($object->parent, 'Net::GPSD3'); is($object->string, $string, 'string'); is($object->class, 'VERSION', 'class'); is($object->release, '2.96~dev', 'release'); is($object->rev, '2011-03-17T02:51:23', 'rev'); is($object->revision, '2011-03-17T02:51:23', 'revision'); is($object->proto_major, '3', 'proto_major'); is($object->proto_minor, '4', 'proto_minor'); is($object->proto, '3.4', 'proto'); is($object->protocol, '3.4', 'protocol'); Net-GPSD3-0.19/t/010_SUBFRAME.t0000644000076400007640000000132011677240251014564 0ustar mdavismdavis# -*- perl -*- use strict; use warnings; use Test::More tests => 7; BEGIN { use_ok( 'Net::GPSD3' ); } my $string='{"class":"SUBFRAME","device":"/dev/cuaU0","tSV":11,"TOW17":88935,"frame":5,"scaled":false,"ALMANAC":{"ID":12,"Health":0,"e":7742,"toa":15,"deltai":5262,"Omegad":-703,"sqrtA":10554829,"Omega0":11924589,"omega":16078788,"M0":15264683,"af0":2029,"af1":1}}'; my $gpsd=Net::GPSD3->new; isa_ok ($gpsd, 'Net::GPSD3'); my $object=$gpsd->constructor($gpsd->decode($string), string=>$string); isa_ok ($object, 'Net::GPSD3::Return::SUBFRAME'); isa_ok ($object->parent, 'Net::GPSD3'); is($object->class, 'SUBFRAME', 'class'); is($object->string, $string, 'string'); is($object->device, '/dev/cuaU0', 'device'); Net-GPSD3-0.19/t/002_ERROR.t0000644000076400007640000000103011677240107014250 0ustar mdavismdavis# -*- perl -*- use strict; use warnings; use Test::More tests => 7; BEGIN { use_ok( 'Net::GPSD3' ); } my $string=q({"class":"ERROR","message":"Unrecognized request 'FOO'"}); my $gpsd=Net::GPSD3->new; isa_ok ($gpsd, 'Net::GPSD3'); my $object=$gpsd->constructor($gpsd->decode($string), string=>$string); isa_ok ($object, 'Net::GPSD3::Return::ERROR'); isa_ok ($object->parent, 'Net::GPSD3'); is($object->string, $string, 'string'); is($object->class, 'ERROR', 'class'); is($object->message, "Unrecognized request 'FOO'", 'message'); Net-GPSD3-0.19/t/007_DEVICE.t0000644000076400007640000000236411677240174014342 0ustar mdavismdavis# -*- perl -*- use strict; use warnings; use Test::More tests => 17; BEGIN { use_ok( 'Net::GPSD3' ); } #my $string=q({"class":"DEVICE","path":"/dev/ttyUSB0","activated":1253333674.67,"flags":1,"driver":"Generic NMEA","native":0,"bps":4800,"parity":"N","stopbits":1,"cycle":1.00}); my $string='{ "class":"DEVICE", "path":"/dev/cuaU0", "activated":1300601059.18, "flags":1, "driver":"uBlox UBX binary", "native":1, "bps":9600, "parity":"N", "stopbits":1, "cycle":1.00, "mincycle":0.25}'; my $gpsd=Net::GPSD3->new; isa_ok ($gpsd, 'Net::GPSD3'); my $object=$gpsd->constructor($gpsd->decode($string), string=>$string); isa_ok ($object, 'Net::GPSD3::Return::DEVICE'); isa_ok ($object->parent, 'Net::GPSD3'); is($object->class, 'DEVICE', 'class'); is($object->string, $string, 'string'); is($object->class, 'DEVICE', 'class'); is($object->path, '/dev/cuaU0', 'path'); is($object->activated, '1300601059.18', 'activated'); is($object->flags, '1', 'flags'); is($object->driver, 'uBlox UBX binary', 'driver'); is($object->native, '1', 'native'); is($object->bps, '9600', 'bps'); is($object->parity, 'N', 'parity'); is($object->stopbits, '1', 'stopbits'); is($object->cycle, 1, 'cycle'); is($object->mincycle, 0.25, 'cycle'); Net-GPSD3-0.19/t/009_WATCH.t0000644000076400007640000000207711677240235014252 0ustar mdavismdavis# -*- perl -*- use strict; use warnings; use Test::More tests => 18; BEGIN { use_ok( 'JSON::XS' ); } BEGIN { use_ok( 'Net::GPSD3' ); } #my $string=q({"class":"WATCH","enable":false,"raw":0,"scaled":false}); my $string='{"class":"WATCH","enable":true,"json":true,"nmea":false,"raw":0,"scaled":false,"timing":false}'; my $gpsd=Net::GPSD3->new; isa_ok ($gpsd, 'Net::GPSD3'); my $object=$gpsd->constructor($gpsd->decode($string), string=>$string); isa_ok ($object, 'Net::GPSD3::Return::WATCH'); isa_ok ($object->parent, 'Net::GPSD3'); is($object->string, $string, 'string'); is($object->class, 'WATCH', 'class'); isa_ok($object->enabled, 'JSON::XS::Boolean', 'enabled'); ok($object->enabled, "enabled"); isa_ok($object->enable, 'JSON::XS::Boolean', 'enable'); ok($object->enable, "enable"); is($object->raw, '0', 'raw'); isa_ok($object->nmea, 'JSON::XS::Boolean', 'nmea'); ok(!$object->nmea, 'nmea'); isa_ok($object->scaled, 'JSON::XS::Boolean', 'scaled'); ok(!$object->scaled, 'scaled'); isa_ok($object->timing, 'JSON::XS::Boolean', 'timing'); ok(!$object->timing, 'timing'); Net-GPSD3-0.19/t/009_POLL.t0000644000076400007640000000547411677244130014154 0ustar mdavismdavis# -*- perl -*- use strict; use warnings; use Test::More tests => 24; BEGIN { use_ok( 'Net::GPSD3' ); } my $string='{ "class":"POLL", "timestamp":"2011-03-20T04:12:25.64Z", "active":1, "tpv":[ { "class":"TPV", "tag":"0x0130", "device":"/dev/cuaU0", "time":"2011-03-20T04:12:25.00Z", "ept":0.005, "lat":37.371425314, "lon":-122.015172578, "alt":25.817, "epx":2.436, "epy":2.863, "epv":11.040, "track":0.0000, "speed":0.000, "climb":0.000, "eps":5.73, "mode":3 } ], "gst":[{ "class":"GST","tag":"0x0130","device":"/dev/cuaU0","time":"1970-01-01T00:00:00.00Z", "rms":0.000,"major":0.000,"minor":0.000,"orient":0.000,"lat":0.000,"lon":0.000,"alt":0.000 }], "sky":[ { "class":"SKY", "tag":"0x0130", "device":"/dev/cuaU0", "xdop":0.65, "ydop":0.76, "vdop":1.30, "tdop":0.80, "hdop":1.00, "gdop":1.83, "pdop":1.64, "satellites":[ {"PRN":28,"el":59,"az":248,"ss":24,"used":true}, {"PRN":13,"el":32,"az":150,"ss":30,"used":true}, {"PRN":7,"el":60,"az":59,"ss":28,"used":true}, {"PRN":10,"el":19,"az":227,"ss":22,"used":false}, {"PRN":19,"el":29,"az":57,"ss":22,"used":true}, {"PRN":5,"el":21,"az":276,"ss":36,"used":true}, {"PRN":3,"el":6,"az":38,"ss":15,"used":false}, {"PRN":8,"el":62,"az":342,"ss":30,"used":true}, {"PRN":26,"el":22,"az":318,"ss":31,"used":false}, {"PRN":11,"el":10,"az":114,"ss":21,"used":false}, {"PRN":138,"el":44,"az":157,"ss":41,"used":true}, {"PRN":17,"el":10,"az":187,"ss":29,"used":false} ]}]}'; my $gpsd=Net::GPSD3->new; isa_ok ($gpsd, 'Net::GPSD3'); my $object=$gpsd->constructor($gpsd->decode($string), string=>$string); isa_ok ($object, 'Net::GPSD3::Return::POLL'); isa_ok ($object->parent, 'Net::GPSD3'); is($object->string, $string, 'string'); is($object->class, 'POLL', 'class'); is($object->active, "1", "active"); is($object->time, "1300594345.64", "time"); is($object->timestamp, "2011-03-20T04:12:25.64Z", "timestamp"); isa_ok($object->_skyviews, "ARRAY", "skyviews"); is(scalar(@{$object->_skyviews}), 1, "sizeof"); isa_ok($object->_skyviews->[0], "HASH"); isa_ok($object->_fixes, "ARRAY", "fixes"); is(scalar(@{$object->_fixes}), 1, "sizeof"); isa_ok($object->_fixes->[0], "HASH"); isa_ok($object->Skyviews, "ARRAY", "Skyviews"); is(scalar(@{$object->Skyviews}), 1, "sizeof"); isa_ok($object->Skyviews->[0], "Net::GPSD3::Return::SKY"); isa_ok($object->Skyviews->[0]->Satellites, "ARRAY"); isa_ok($object->Fixes, "ARRAY", "Fixes"); is(scalar(@{$object->Fixes}), 1, "sizeof"); isa_ok($object->Fixes->[0], "Net::GPSD3::Return::TPV"); isa_ok($object->sky, "Net::GPSD3::Return::SKY"); isa_ok($object->fix, "Net::GPSD3::Return::TPV"); Net-GPSD3-0.19/t/001_load.t0000644000076400007640000000615311677240073014312 0ustar mdavismdavis# -*- perl -*- use strict; use warnings; use Test::More tests => 54; BEGIN { use_ok( 'Net::GPSD3' ); } BEGIN { use_ok( 'Net::GPSD3::Base' ); } BEGIN { use_ok( 'Net::GPSD3::Cache' ); } BEGIN { use_ok( 'Net::GPSD3::Return::DEVICE' ); } BEGIN { use_ok( 'Net::GPSD3::Return::DEVICES' ); } BEGIN { use_ok( 'Net::GPSD3::Return::ERROR' ); } BEGIN { use_ok( 'Net::GPSD3::Return::Satellite' ); } BEGIN { use_ok( 'Net::GPSD3::Return::GST' ); } BEGIN { use_ok( 'Net::GPSD3::Return::SKY' ); } BEGIN { use_ok( 'Net::GPSD3::Return::TPV' ); } BEGIN { use_ok( 'Net::GPSD3::Return::Unknown' ); } BEGIN { use_ok( 'Net::GPSD3::Return::Unknown::Timestamp' ); } BEGIN { use_ok( 'Net::GPSD3::Return::VERSION' ); } BEGIN { use_ok( 'Net::GPSD3::Return::WATCH' ); } my $object; $object = Net::GPSD3->new(); isa_ok ($object, 'Net::GPSD3'); isa_ok ($object, 'Net::GPSD3::Base'); $object = Net::GPSD3::Base->new(); isa_ok ($object, 'Net::GPSD3::Base'); $object = Net::GPSD3::Cache->new(); isa_ok ($object, 'Net::GPSD3::Cache'); isa_ok ($object, 'Net::GPSD3::Base'); $object = Net::GPSD3::Return::DEVICE->new(); isa_ok ($object, 'Net::GPSD3::Return::DEVICE'); isa_ok ($object, 'Net::GPSD3::Return::Unknown'); isa_ok ($object, 'Net::GPSD3::Base'); $object = Net::GPSD3::Return::DEVICES->new(); isa_ok ($object, 'Net::GPSD3::Return::DEVICES'); isa_ok ($object, 'Net::GPSD3::Return::Unknown'); isa_ok ($object, 'Net::GPSD3::Base'); $object = Net::GPSD3::Return::ERROR->new(); isa_ok ($object, 'Net::GPSD3::Return::ERROR'); isa_ok ($object, 'Net::GPSD3::Return::Unknown'); isa_ok ($object, 'Net::GPSD3::Base'); $object = Net::GPSD3::Return::Satellite->new(); isa_ok ($object, 'Net::GPSD3::Return::Satellite'); isa_ok ($object, 'Net::GPSD3::Return::Unknown'); isa_ok ($object, 'Net::GPSD3::Base'); $object = Net::GPSD3::Return::GST->new(); isa_ok ($object, 'Net::GPSD3::Return::GST'); isa_ok ($object, 'Net::GPSD3::Return::Unknown::Timestamp'); isa_ok ($object, 'Net::GPSD3::Return::Unknown'); isa_ok ($object, 'Net::GPSD3::Base'); $object = Net::GPSD3::Return::SKY->new(); isa_ok ($object, 'Net::GPSD3::Return::SKY'); isa_ok ($object, 'Net::GPSD3::Return::Unknown::Timestamp'); isa_ok ($object, 'Net::GPSD3::Return::Unknown'); isa_ok ($object, 'Net::GPSD3::Base'); $object = Net::GPSD3::Return::TPV->new(); isa_ok ($object, 'Net::GPSD3::Return::TPV'); isa_ok ($object, 'Net::GPSD3::Return::Unknown::Timestamp'); isa_ok ($object, 'Net::GPSD3::Return::Unknown'); isa_ok ($object, 'Net::GPSD3::Base'); $object = Net::GPSD3::Return::Unknown->new(); isa_ok ($object, 'Net::GPSD3::Return::Unknown'); isa_ok ($object, 'Net::GPSD3::Base'); $object = Net::GPSD3::Return::Unknown::Timestamp->new(); isa_ok ($object, 'Net::GPSD3::Return::Unknown::Timestamp'); isa_ok ($object, 'Net::GPSD3::Return::Unknown'); isa_ok ($object, 'Net::GPSD3::Base'); $object = Net::GPSD3::Return::VERSION->new(); isa_ok ($object, 'Net::GPSD3::Return::VERSION'); isa_ok ($object, 'Net::GPSD3::Return::Unknown'); isa_ok ($object, 'Net::GPSD3::Base'); $object = Net::GPSD3::Return::WATCH->new(); isa_ok ($object, 'Net::GPSD3::Return::WATCH'); isa_ok ($object, 'Net::GPSD3::Return::Unknown'); isa_ok ($object, 'Net::GPSD3::Base'); Net-GPSD3-0.19/t/006_DEVICES.t0000644000076400007640000000423511677240163014461 0ustar mdavismdavis# -*- perl -*- use strict; use warnings; use Test::More tests => 27; BEGIN { use_ok( 'Net::GPSD3' ); } #my $string=q({"class":"DEVICES","devices":[{"class":"DEVICE","path":"/dev/ttyUSB0","activated":1253333674.67,"flags":1,"driver":"Generic NMEA","native":0,"bps":4800,"parity":"N","stopbits":1,"cycle":1.00}]}); my $string='{ "class":"DEVICES", "devices":[{ "class":"DEVICE", "path":"/dev/cuaU0", "activated":1300601059.18, "flags":1, "driver":"uBlox UBX binary", "native":1, "bps":9600, "parity":"N", "stopbits":1, "cycle":1.00, "mincycle":0.25}]}'; my $gpsd=Net::GPSD3->new; isa_ok($gpsd, 'Net::GPSD3'); my $object=$gpsd->constructor($gpsd->decode($string), string=>$string); isa_ok($object, 'Net::GPSD3::Return::DEVICES'); isa_ok($object->parent, 'Net::GPSD3'); is($object->class, 'DEVICES', 'class'); is($object->string, $string, 'string'); my $devices; my @devices; $devices=$object->devices; isa_ok($devices, 'ARRAY', 'devices'); isa_ok($devices->[0], 'HASH', 'devices'); @devices=$object->devices; is(scalar(@devices), '1', 'devices'); isa_ok($devices[0], 'HASH', 'devices'); $devices=$object->Devices; isa_ok($devices, 'ARRAY', 'devices'); isa_ok($devices->[0], 'Net::GPSD3::Return::DEVICE', 'Devices'); @devices=$object->Devices; is(scalar(@devices), '1', 'Devices'); isa_ok($devices[0], 'Net::GPSD3::Return::DEVICE', 'Devices'); my $device=$devices->[0]; isa_ok($device, 'Net::GPSD3::Return::DEVICE', 'Devices'); is($device->class, 'DEVICE', 'class'); isa_ok ($device->parent, 'Net::GPSD3'); #Current architecture does not keep order... #is($device->string, '{"class":"DEVICE","path":"/dev/ttyUSB0","activated":1253333674.67,"flags":1,"driver":"Generic NMEA","native":0,"bps":4800,"parity":"N","stopbits":1,"cycle":1.00}', 'string'); is($device->path, '/dev/cuaU0', 'path'); is($device->activated, '1300601059.18', 'activated'); is($device->flags, '1', 'flags'); is($device->driver, 'uBlox UBX binary', 'driver'); is($device->native, '1', 'native'); is($device->bps, '9600', 'bps'); is($device->parity, 'N', 'parity'); is($device->stopbits, '1', 'stopbits'); is($device->cycle, 1, 'cycle'); is($device->mincycle, 0.25, 'cycle'); Net-GPSD3-0.19/LICENSE0000644000076400007640000000276111326333640013363 0ustar mdavismdavisThe BSD License Copyright (c) 2009, Michael R. Davis All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the STOP, LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Net-GPSD3-0.19/MANIFEST0000644000076400007640000000161011677244637013517 0ustar mdavismdavisChanges lib/Net/GPSD3.pm lib/Net/GPSD3/Base.pm lib/Net/GPSD3/Cache.pm lib/Net/GPSD3/Return/DEVICE.pm lib/Net/GPSD3/Return/DEVICES.pm lib/Net/GPSD3/Return/ERROR.pm lib/Net/GPSD3/Return/GST.pm lib/Net/GPSD3/Return/POLL.pm lib/Net/GPSD3/Return/Satellite.pm lib/Net/GPSD3/Return/SKY.pm lib/Net/GPSD3/Return/SUBFRAME.pm lib/Net/GPSD3/Return/TPV.pm lib/Net/GPSD3/Return/Unknown.pm lib/Net/GPSD3/Return/Unknown/Timestamp.pm lib/Net/GPSD3/Return/VERSION.pm lib/Net/GPSD3/Return/WATCH.pm LICENSE Makefile.PL MANIFEST README scripts/perl-Net-GPSD3-Example.pl scripts/perl-Net-GPSD3-Handler.pl scripts/perl-Net-GPSD3-poll.pl t/001_load.t t/002_ERROR.t t/003_TPV.t t/004_SKY.t t/005_Satellite.t t/006_DEVICES.t t/007_DEVICE.t t/008_VERSION.t t/009_POLL.t t/009_POLL_transitional.t t/009_WATCH.t t/010_SUBFRAME.t Todo perl-Net-GPSD3.spec META.yml Module meta-data (added by MakeMaker) Net-GPSD3-0.19/lib/0000755000076400007640000000000011677244637013136 5ustar mdavismdavisNet-GPSD3-0.19/lib/Net/0000755000076400007640000000000011677244637013664 5ustar mdavismdavisNet-GPSD3-0.19/lib/Net/GPSD3.pm0000644000076400007640000002460611677243465015050 0ustar mdavismdavispackage Net::GPSD3; use strict; use warnings; use base qw{Net::GPSD3::Base}; use JSON::XS qw{}; use IO::Socket::INET6 qw{}; use Net::GPSD3::Return::Unknown; use Net::GPSD3::Cache; use DateTime; our $VERSION='0.19'; our $PACKAGE=__PACKAGE__; =head1 NAME Net::GPSD3 - Interface to the gpsd server daemon protocol versions 3 (JSON). =head1 SYNOPSIS =head2 Watch Interface use Net::GPSD3; my $gpsd=Net::GPSD3->new; $gpsd->watch; One Liner perl -MNet::GPSD3 -e 'Net::GPSD3->new->watch' =head2 Poll Interface use Net::GPSD3; use Data::Dumper qw{Dumper}; my $gpsd=Net::GPSD3->new; my $poll=$gpsd->poll; print Dumper($poll); One Liner perl -MNet::GPSD3 -e 'printf "Protocol: %s\n", Net::GPSD3->new->poll->parent->cache->VERSION->protocol;' Protocol: 3.4 =head2 POE Interface See L =head1 DESCRIPTION Net::GPSD3 provides an object client interface to the gpsd server daemon utilizing the version 3 protocol. gpsd is an open source GPS daemon from http://www.catb.org/gpsd/ Support for Version 3 of the protocol (JSON) was added to the daemon in version 2.90. If your daemon is before 2.90 (protocol 2.X), please use the L package. =head1 CONSTRUCTOR =head2 new Returns a new Net::GPSD3 object. my $gpsd=Net::GPSD3->new; my $gpsd=Net::GPSD3->new(host=>"127.0.0.1", port=>2947); #defaults =head1 METHODS =head2 host Sets or returns the current gpsd host. my $host=$obj->host; =cut sub host { my $self=shift; if (@_) { $self->{'host'}=shift; undef($self->{'socket'}); } $self->{'host'}="127.0.0.1" unless defined $self->{'host'}; return $self->{'host'}; } =head2 port Sets or returns the current gpsd TCP port. my $port=$obj->port; =cut sub port { my $self=shift; if (@_) { $self->{'port'}=shift; undef($self->{'socket'}); } $self->{'port'}='2947' unless defined $self->{'port'}; return $self->{'port'}; } =head2 poll Sends a Poll request to the gpsd server and returns a L object. The method also populates the cache object with the L and L objects. my $poll=$gpsd->poll; #isa Net::GPSD3::Return::POLL object Note: In order to use the poll method consistently you should run the GPSD daemon as a service. You may also need to run the daemon with the "-n" option. =cut sub poll { my $self=shift; $self->socket->send(qq(?DEVICES;\n)) unless $self->cache->DEVICES; $self->socket->send(qq(?POLL;\n)); my $object; do { #Reads and caches VERSION and DEVICES local $/="\r\n"; my $line=$self->socket->getline; chomp $line; $object=$self->constructor($self->decode($line), string=>$line); $self->cache->add($object) unless $object->class eq "POLL"; } until $object->class eq "POLL"; #this needs more logic return $object; } =head2 watch Calls all handlers that are registered in the handler method. $gpsd->watch; #will not return unless something goes wrong. =cut sub watch { my $self=shift; my @handler=$self->handlers; push @handler, \&default_handler unless scalar(@handler); #$self->socket->send(qq(?DEVICES;\n)); #appears this is now done in the daemon $self->socket->send($self->_watch_string_on. "\n"); my $object; #man 8 gpsd - Each request returns a line of response text ended by a CR/LF. local $/="\r\n"; my $line; while (defined($line=$self->socket->getline)) { #Reads VERSION and DEVICES object too. #print "$line\n"; chomp $line; my $object=$self->constructor($self->decode($line), string=>$line); $_->($object) foreach @handler; $self->cache($object); #cache after handler so that the last point is available to the handler. } return $self; } sub _watch_string_on { return q(?WATCH={"enable":true,"json":true};); } sub _watch_string_off { return q(?WATCH={"enable":false,"json":true};); } =head2 addHandler Adds handlers to the handler list. $gpsd->addHandler(\&myHandler); $gpsd->addHandler(\&myHandler1, \&myHandler2); A handler is a sub reference where the first argument is a Net::GPSD3::Return::* object. =cut sub addHandler { my $self=shift; my $array=$self->handlers; push @$array, @_ if @_; return $self; } =head2 handlers List of handlers that are called in order to process objects from the gpsd wathcer stream. my @handler=$gpsd->handlers; #() my $handler=$gpsd->handlers; #[] =cut sub handlers { my $self=shift; $self->{'handler'}=[] unless ref($self->{'handler'}); return wantarray ? @{$self->{'handler'}} : $self->{'handler'}; } =head2 cache Returns the L caching object. =cut sub cache { my $self=shift; $self->{"cache"}=Net::GPSD3::Cache->new(parent=>$self) unless defined $self->{"cache"}; return $self->{"cache"}; } =head1 METHODS Internal =head2 default_handler =cut sub default_handler { my $object=shift; #use Data::Dumper qw{Dumper}; #print Dumper($object); if ($object->class eq "TPV") { printf "%s: %s, Time: %s, Lat: %s, Lon: %s, Speed: %s, Heading: %s\n", DateTime->now, $object->class, $object->timestamp, $object->lat, $object->lon, $object->speed, $object->track; } elsif ($object->class eq "SKY") { printf "%s: %s, Satellites: %s, Used: %s, PRNs: %s\n", DateTime->now, $object->class, $object->reported, $object->used, join(",", map {$_->prn} grep {$_->used} $object->Satellites), } elsif ($object->class eq "SUBFRAME") { printf qq{%s: %s, Device: %s\n}, DateTime->now, $object->class, $object->device; } elsif ($object->class eq "VERSION") { printf "%s: %s, GPSD: %s (%s), %s: %s\n", DateTime->now, $object->class, $object->release, $object->revision, ref($object->parent), $object->parent->VERSION; } elsif ($object->class eq "WATCH") { printf "%s: %s, Enabled: %s\n", DateTime->now, $object->class, $object->enabled; } elsif ($object->class eq "DEVICES") { my @device=$object->Devices; foreach my $device (@device) { if ($device->activated) { $device=sprintf("%s (%s bps %s-%s)", $device->path, $device->bps, $device->driver, $device->subtype); } else { $device=$device->path; } } printf "%s: %s, Devices: %s\n", DateTime->now, $object->class, join(", ", @device); } elsif ($object->class eq "DEVICE") { printf qq{%s: %s, Device: %s (%s bps %s-%s)\n}, DateTime->now, $object->class, $object->path, $object->bps, $object->driver, $object->subtype; } elsif ($object->class eq "ERROR") { printf qq{%s: %s, Message: "%s"\n}, DateTime->now, $object->class, $object->message; } else { warn(sprintf(qq{Warning: Unknown class "%s" for object "%s".}, $object->class, ref($object))); #print Dumper($object); } #print Dumper($object); } =head2 socket Returns the cached L object my $socket=$gpsd->socket; #try to reconnect on failure =cut sub socket { my $self=shift; unless (defined($self->{'socket'}) and defined($self->{'socket'}->connected)) { $self->{"socket"}=IO::Socket::INET6->new( PeerAddr => $self->host, PeerPort => $self->port, ); die(sprintf("Error: Cannot connect to gpsd://%s:%s/.\n", $self->host, $self->port)) unless defined($self->{"socket"}); } return $self->{'socket'}; } =head2 json Returns the cached L object =cut sub json { my $self=shift; #Do I need to support JSON::PP? $self->{"json"}=JSON::XS->new unless ref($self->{"json"}) eq "JSON::XS"; return $self->{"json"}; } =head2 decode Returns a perl data structure given a JSON formated string. my %data=$gpsd->decode($string); #() my $data=$gpsd->decode($string); #{} =cut sub decode { my $self=shift; my $string=shift; my $data=eval {$self->json->decode($string)}; if ($@) { $data={class=>"ERROR", message=>"Invalid JSON"}; } return wantarray ? %$data : $data; } =head2 encode Returns a JSON string from a perl data structure =cut sub encode { my $self=shift; my $data=shift; my $string=$self->json->encode($data); return $string; } =head2 constructor Constructs a class object by lazy loading the classes. my $obj=$gpsd->constructor(%$data); my $obj=$gpsd->constructor(class=>"DEVICE", string=>'{...}', ...); Returns and object in the Net::GPSD3::Return::* namespace. =cut sub constructor { my $self=shift; my %data=@_; $data{"class"}||="undef"; my $class=join("::", $PACKAGE, "Return", $data{"class"}); my $object; eval("use $class"); if ($@) { #Failed to load class $object=Net::GPSD3::Return::Unknown->new(parent=>$self, %data); } else { $object=$class->new(parent=>$self, %data); } return $object; } =head1 BUGS Log on RT and Send to gpsd-dev email list There are no two GPS devices that are alike. Each GPS device has a different GPSD signature as well. If your GPS device does not work out of the box with this package, please send me a log of your devices JSON sentences. echo '?POLL;' | nc 127.0.0.1 2947 echo '?WATCH={"enable":true,"json":true};' | socat -t10 stdin stdout | nc 127.0.0.1 2947 =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L, L, L, L, L, L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/0000755000076400007640000000000011677244637014504 5ustar mdavismdavisNet-GPSD3-0.19/lib/Net/GPSD3/Return/0000755000076400007640000000000011677244637015763 5ustar mdavismdavisNet-GPSD3-0.19/lib/Net/GPSD3/Return/DEVICE.pm0000644000076400007640000000542211543447272017253 0ustar mdavismdavispackage Net::GPSD3::Return::DEVICE; use strict; use warnings; use base qw{Net::GPSD3::Return::Unknown}; our $VERSION='0.14'; =head1 NAME Net::GPSD3::Return::DEVICE - Net::GPSD3 Return DEVICE Object =head1 SYNOPSIS =head1 DESCRIPTION Provides a Perl object interface to the DEVICE object returned by the GPSD daemon. =head1 METHODS =head2 class Returns the object class =head2 string Returns the JSON string =head2 parent Return the parent L object =head2 device Name the device for which the control bits are being reported, or for which they are to be applied. This attribute may be omitted only when there is exactly one subscribed channel. =cut sub device {shift->{"device"}}; =head2 driver GPSD's name for the device driver type. Won't be reported before gpsd has seen identifiable packets from the device. =cut sub driver {shift->{"driver"}||'none'}; =head2 subtype Whatever version information the device returned. =cut sub subtype {shift->{"subtype"}||'none'}; =head2 path =cut sub path {shift->{"path"}}; =head2 native 0 means NMEA mode and 1 means alternate mode (binary if it has one, for SiRF and Evermore chipsets in particular). Attempting to set this mode on a non-GPS device will yield an error. =cut sub native {shift->{"native"}}; =head2 activated Time the device was activated, or 0 if it is being closed. Note: I expect this to change to either a boolean or a timestamp in the 3.5 protocol. =cut sub activated {shift->{"activated"}}; =head2 cycle Device cycle time in seconds. =cut sub cycle {shift->{"cycle"}}; =head2 mincycle Device minimum cycle time in seconds. Reported from ?CONFIGDEV when (and only when) the rate is switchable. It is read-only and not settable. =cut sub mincycle {shift->{"mincycle"}}; =head2 flags Bit vector of property flags. Currently defined flags are: describe packet types seen so far (GPS, RTCM2, RTCM3, AIS). Won't be reported if empty, e.g. before gpsd has seen identifiable packets from the device. =cut sub flags {shift->{"flags"}}; =head2 bps Device speed in bits per second. =cut sub bps {shift->{"bps"}}; =head2 parity N, O or E for no parity, odd, or even. =cut sub parity {shift->{"parity"}}; =head2 stopbits Stop bits (1 or 2). =cut sub stopbits {shift->{"stopbits"}}; =head1 BUGS Log on RT and Send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/Return/TPV.pm0000644000076400007640000001267311542560575016774 0ustar mdavismdavispackage Net::GPSD3::Return::TPV; use strict; use warnings; use base qw{Net::GPSD3::Return::Unknown::Timestamp}; use GPS::Point; our $VERSION='0.12'; =head1 NAME Net::GPSD3::Return::TPV - Net::GPSD3 Return TPV Object =head1 SYNOPSIS printf "Time: %s, Lat: %s, Lon: %s\n", $object->time, $object->lat, $object->lon; =head1 DESCRIPTION Provides a Perl object interface to the Time-Velocity-Position (TVP) object returned by the GPSD daemon. Example JSON objects: =head3 Protocol 3.1 Versions { "class":"TPV", "tag":"MID2", "device":"/dev/ttyUSB0", "time":1253593085.470, "ept":0.005, "lat":38.88945123, "lon":-77.03522143, "track":171.7249, "speed":0.467, "mode":2 } { "class":"TPV", "tag":"MID2", "device":"/dev/ttyUSB0", "time":1253593667.430, "ept":0.005, "lat":38.88945123, "lon":-77.03522143, "alt":146.911, "track":180.0000, "speed":0.194, "climb":-0.157, "mode":3 } =head3 Protocol 3.4 Version { "class":"TPV", "tag":"0x0106", "device":"/dev/cuaU0", "time":"2011-03-20T06:51:59.12Z", "ept":0.005, "lat":37.371427205, "lon":-122.015179890, "alt":25.789, "epx":1.926, "epy":1.808, "epv":6.497, "track":0.0000, "speed":0.000, "climb":0.000, "eps":3.85, "mode":3 } =head1 METHODS PROPERTIES =head2 class Returns the object class =head2 string Returns the JSON string =head2 parent Return the parent Net::GPSD object =head2 device Name of originating device. =cut sub device {shift->{"device"}}; =head2 tag Type tag associated with this GPS sentence; from an NMEA device this is just the NMEA sentence type. =cut sub tag {shift->{"tag"}}; =head2 mode NMEA mode: %d, 0=no mode value yet seen, 1=no fix, 2=2D, 3=3D. =cut sub mode {shift->{"mode"}}; =head2 time Seconds since the Unix epoch, UTC. The value may have a fractional part of up to .01sec precision. Note: In 2.96 (protocol 3.4) the TPV->time format changed from unix epoch to W3C, but this method hides that from the user. =head2 timestamp W3C formated timestamp value either directly from the protocol >= 3.4 or calculated < 3.4. The value may have a fractional part of up to .01sec precision. Note: I expect that in protocol 3.5 the value will be passed directly as TPV->timestamp =head2 datetime Returns a L object =head2 lat Latitude in degrees: +/- signifies West/East =cut sub lat {shift->{"lat"}}; =head2 lon Longitude in degrees: +/- signifies North/South. =cut sub lon {shift->{"lon"}}; =head2 alt Altitude in meters. =cut sub alt {shift->{"alt"}}; =head2 speed Speed over ground, meters per second. =cut sub speed {shift->{"speed"}}; =head2 track Course over ground, degrees from true north. =cut sub track {shift->{"track"}}; =head2 climb Climb (postive) or sink (negative) rate, meters per second. =cut sub climb {shift->{"climb"}}; =head2 ept Estimated timestamp error (%f, seconds, 95% confidence). =cut sub ept {shift->{"ept"}}; =head2 epx =cut sub epx {shift->{"epx"}}; =head2 epy Latitude error estimate in meters, 95% confidence. =cut sub epy {shift->{"epy"}}; =head2 epv Estimated vertical error in meters, 95% confidence. =cut sub epv {shift->{"epv"}}; =head2 eps Speed error estimate in meters/sec, 95% confifdence. =cut sub eps {shift->{"eps"}}; =head2 epd Direction error estinmate in degrees, 95% confifdence. =cut sub epd {shift->{"epd"}}; =head2 epc Climb/sink error estinmate in meters/sec, 95% confifdence. =cut sub epc {shift->{"epc"}}; =head1 METHODS VALUE ADDED =head2 point Returns a L Object =cut sub point { my $self=shift; unless (defined($self->{"point"})) { $self->{"point"}=GPS::Point->new( time => $self->datetime->hires_epoch, #float seconds from the unix epoch timestamp => $self->timestamp, #not yet supported but I'm planning it datetime => $self->datetime, #not yet supported but I'm planning it lat => $self->lat, #signed degrees lon => $self->lon, #signed degrees alt => $self->alt, #meters above the WGS-84 ellipsoid speed => $self->speed, #meters/second (over ground) heading => $self->track, #degrees clockwise from North climb => $self->climb, #meters/second etime => $self->ept, #float seconds ehorizontal => $self->epx, #float meters evertical => $self->epv, #float meters espeed => $self->eps, #meters/second eheading => $self->epd, #degrees eclimb => $self->epc, #meters/second mode => $self->mode, #GPS mode [?=>undef,None=>1,2D=>2,3D=>3] tag => $self->tag, #Name of the GPS message for data ); } return $self->{"point"}; } =head1 BUGS Log on RT and Send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L, L, L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/Return/Unknown.pm0000644000076400007640000000272711542556120017750 0ustar mdavismdavispackage Net::GPSD3::Return::Unknown; use strict; use warnings; use base qw{Net::GPSD3::Base}; our $VERSION='0.12'; =head1 NAME Net::GPSD3::Return::Unknown - Net::GPSD3 Return Base Class =head1 SYNOPSIS use base qw{Net::GPSD3::Return::Unknown}; =head1 DESCRIPTION Provides the base Perl object interface to all objects returned by the GPSD daemon. This class is also used if the class is unknown. =head1 METHODS =head2 parent Returns the parent Net::GPSD3 object =cut sub parent {shift->{"parent"}}; =head2 class Returns the class string for the particular JSON message. Classes in all upper case are from gpsd. Classes with initial capital letter are from this Perl package. Class in all lower case are currently reserved. Private extension classes should use camel case. =cut sub class {shift->{"class"}}; =head2 string This is the JSON string as passed over the TCP connection. =cut sub string {shift->{"string"}}; =head1 BUGS Log on RT and Send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L, L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/Return/DEVICES.pm0000644000076400007640000000344111542556044017372 0ustar mdavismdavispackage Net::GPSD3::Return::DEVICES; use strict; use warnings; use base qw{Net::GPSD3::Return::Unknown}; our $VERSION='0.12'; =head1 NAME Net::GPSD3::Return::DEVICES - Net::GPSD3 Return DEVICES Object =head1 SYNOPSIS =head1 DESCRIPTION Provides a Perl object interface to the DEVICE object returned by the GPSD daemon. =head1 METHODS =head2 class Returns the object class =head2 string Returns the JSON string =head2 parent Return the parent Net::GPSD object =head2 devices Returns a list of device data structures. my @device=$devices->devices; #({},...) my @device=$devices->devices; #[{},...] =cut sub devices { my $self=shift; $self->{"devices"}=[] unless ref($self->{"devices"}) eq "ARRAY"; return wantarray ? @{$self->{"devices"}} : $self->{"devices"}; } =head2 Devices Returns a list of L objects. my @device=$devices->Devices; #(bless{},...) my @device=$devices->Devices; #[bless{},...] =cut sub Devices { my $self=shift; unless (defined $self->{"Devices"}) { $self->{"Devices"}=[ map {$self->parent->constructor(%$_, string=>$self->parent->encode($_))} grep {ref($_) eq "HASH"} $self->devices]; } return wantarray ? @{$self->{"Devices"}} : $self->{"Devices"}; } =head1 BUGS Log on RT and Send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L, L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/Return/Unknown/0000755000076400007640000000000011677244637017422 5ustar mdavismdavisNet-GPSD3-0.19/lib/Net/GPSD3/Return/Unknown/Timestamp.pm0000644000076400007640000000730411676247077021727 0ustar mdavismdavispackage Net::GPSD3::Return::Unknown::Timestamp; use strict; use warnings; use base qw{Net::GPSD3::Return::Unknown}; use DateTime::Format::W3CDTF; use DateTime; our $VERSION='0.18'; =head1 NAME Net::GPSD3::Return::Unknown::Timestamp - Net::GPSD3 Return Base Class with Timestamp =head1 SYNOPSIS package XXX; use base qw{Net::GPSD3::Return::Unknown::Timestamp}; =head1 DESCRIPTION Provides a time, timestamp and datetime methods to a GPSD3 Return object. =head1 METHODS =head2 time Seconds since the Unix epoch, UTC. The value may have a fractional part of up to .01sec precision. Note: In 2.96 (protocol 3.4) the TPV->time format changed from unix epoch to W3C, but this method attempts to hide that change from the user. Since the POSIX standard for the Unix epoch does not use leap seconds but GPS system does I do not recommend that you use this method for time display or storage. This method is purely here for backwards compatibility. =cut sub time { my $self=shift; #protocol < 3.4 $self->timestamp unless defined $self->{"_time"}; $self->{"_time"}=$self->datetime->hires_epoch unless defined $self->{"_time"}; return $self->{"_time"}; } =head2 timestamp W3C formated timestamp value either directly from the protocol >= 3.4 or calculated < 3.4. The value may have a fractional part of up to .01sec precision. Note: I expect that in protocol 3.5 the value will be passed directly as TPV->timestamp =cut sub timestamp { my $self=shift; unless (defined $self->{"_timestamp"}) { my $qr=qr/\A\d{4}\-\d{2}\-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d*)?Z\Z/; if (defined($self->{"timestamp"}) and $self->{"timestamp"} =~ $qr) { #protocol 3.5 (expected) $self->{"_timestamp"}=$self->{"timestamp"} } elsif (defined($self->{"time"}) and $self->{"time"} =~ $qr) { #protocol 3.4 $self->{"_timestamp"}=$self->{"time"}; } elsif (defined($self->{"time"}) and $self->{"time"} =~ m/^\d{1,}(?:\.\d*)?$/) { #protocol < 3.4 $self->{"_time"}=$self->{"time"} unless defined $self->{"_time"}; $self->{"_timestamp"}=$self->datetime->strftime(q{%FT%T.%2NZ}); #%2N truncates should round DateTime 0.66 } else { die("Error: Either TPV->timestamp or TPV->time must be defined."); } } return $self->{"_timestamp"}; } =head2 datetime Returns a L object =cut sub datetime { my $self=shift; unless (defined($self->{"datetime"})) { my $timestamp=$self->{"_timestamp"} || $self->{"timestamp"} || #protocol >= 3.5 (expected) undef; if (defined $timestamp) { $self->{"datetime"}=DateTime::Format::W3CDTF->new->parse_datetime($timestamp); $self->{"_time"}=$self->datetime->hires_epoch unless defined $self->{"_time"}; } elsif (defined $self->{"_time"}) { $self->{"datetime"}=DateTime->from_epoch(epoch=>$self->{"_time"}, time_zone=>"UTC"); } elsif ($self->timestamp) { #infinate loop potential $self->{"datetime"}=DateTime::Format::W3CDTF->new->parse_datetime($self->timestamp); } else { die("Error: Either TPV->timestamp or TPV->time must be defined."); } } return $self->{"datetime"}; } =head1 BUGS Log on RT and Send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L, L, L, L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/Return/SKY.pm0000644000076400007640000001024511542560756016763 0ustar mdavismdavispackage Net::GPSD3::Return::SKY; use strict; use warnings; use base qw{Net::GPSD3::Return::Unknown::Timestamp}; use DateTime; our $VERSION='0.12'; =head1 NAME Net::GPSD3::Return::SKY - Net::GPSD3 Return SKY Object =head1 SYNOPSIS =head1 DESCRIPTION Provides a Perl object interface to the SKY object returned by the GPSD daemon. An example JSON object: =head3 Protcol 3.1 versions { "class":"SKY", "tag":"MID4", "device":"/dev/ttyUSB0", "time":1253593665.430, "hdop":23.60, "reported":9, "satellites": [ {"PRN":15,"el":77,"az":123,"ss":0, "used":false}, {"PRN":18,"el":25,"az":268,"ss":0, "used":false}, {"PRN":27,"el":13,"az":150,"ss":0, "used":false}, {"PRN":29,"el":47,"az":228,"ss":0, "used":false}, {"PRN":5, "el":39,"az":58, "ss":46,"used":true }, {"PRN":21,"el":41,"az":309,"ss":33,"used":true }, {"PRN":10,"el":32,"az":61, "ss":40,"used":true }, {"PRN":8, "el":12,"az":48, "ss":40,"used":true }, {"PRN":2, "el":9, "az":124,"ss":0, "used":false} ] } =head3 Protcol 3.4 versions { "class":"SKY", "tag":"0x0120", "device":"/dev/cuaU0", "xdop":0.58, "ydop":0.96, "vdop":1.92, "tdop":1.14, "hdop":1.90, "gdop":2.93, "pdop":2.70, "satellites":[ {"PRN":17,"el":76,"az":174,"ss":34,"used":true}, {"PRN":28,"el":57,"az":38,"ss":30,"used":false}, {"PRN":27,"el":22,"az":314,"ss":18,"used":true}, {"PRN":7,"el":15,"az":127,"ss":29,"used":true}, {"PRN":15,"el":31,"az":297,"ss":27,"used":true}, {"PRN":11,"el":18,"az":54,"ss":28,"used":false}, {"PRN":24,"el":18,"az":63,"ss":29,"used":false}, {"PRN":9,"el":4,"az":313,"ss":18,"used":false}, {"PRN":8,"el":45,"az":117,"ss":33,"used":true}, {"PRN":26,"el":49,"az":245,"ss":37,"used":true}, {"PRN":4,"el":5,"az":170,"ss":17,"used":false}, {"PRN":138,"el":44,"az":157,"ss":40,"used":true} ] } =head1 METHODS PROPERTIES =head2 class Returns the object class =head2 string Returns the JSON string =head2 parent Return the parent Net::GPSD object =head2 device =cut sub device {shift->{"device"}}; =head2 tag =cut sub tag {shift->{"tag"}}; =head2 time =head2 timestamp =head2 datetime =head2 reported Count of satellites in view =cut sub reported { my $self=shift; $self->{"reported"}=scalar(@{$self->satellites}) unless defined $self->{"reported"}; return $self->{"reported"}; } =head2 used Count of satellites used in calculation =cut sub used { my $self=shift; $self->{"used"}=scalar(@{[grep {$_->{"used"}} $self->satellites]}) unless defined $self->{"used"}; return $self->{"used"}; } =head2 satellites Returns a list of satellite data structures. my $satellites=$sky->satellites(); #[{},...] my @satellites=$sky->satellites(); #({},...) =cut sub satellites { my $self=shift; unless (ref($self->{"satellites"}) eq "ARRAY") { $self->{"satellites"}=[]; } return wantarray ? @{$self->{"satellites"}} : $self->{"satellites"}; } =head2 Satellites Returns a list of L objects. my @satellites=$sky->Satellites; #(bless{},...) my $satellites=$sky->Satellites; #[bless{},...] =cut sub Satellites { my $self=shift; unless (defined($self->{"Satellites"})) { $self->{"Satellites"}=[ map {$self->parent->constructor(%$_, class=>"Satellite", string=>$self->parent->encode($_))} grep {ref($_) eq "HASH"} $self->satellites]; } return wantarray ? @{$self->{"Satellites"}} : $self->{"Satellites"}; } =head1 BUGS Log on RT and Send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L, L, L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/Return/SUBFRAME.pm0000644000076400007640000000216611542555144017517 0ustar mdavismdavispackage Net::GPSD3::Return::SUBFRAME; use strict; use warnings; use base qw{Net::GPSD3::Return::Unknown}; our $VERSION='0.12'; =head1 NAME Net::GPSD3::Return::SUBFRAME - Net::GPSD3 Return SUBFRAME Object =head1 SYNOPSIS =head1 DESCRIPTION Provides a Perl object interface to the SUBFRAME object returned by the GPSD daemon. An example JSON object: =head1 METHODS PROPERTIES =head2 class Returns the object class =head2 string Returns the JSON string =head2 parent Return the parent Net::GPSD object =head2 device =cut sub device {shift->{"device"}}; =head1 BUGS Log on RT and Send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L, L, L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/Return/Satellite.pm0000644000076400007640000000400111543273620020224 0ustar mdavismdavispackage Net::GPSD3::Return::Satellite; use strict; use warnings; use base qw{Net::GPSD3::Return::Unknown}; our $VERSION='0.13'; =head1 NAME Net::GPSD3::Return::Satellite - Net::GPSD3 Return Satellite Object =head1 SYNOPSIS use Net::GPSD3 0.13; my $gpsd = Net::GPSD3->new; my $poll = $gpsd->poll; #new method in 0.12 my $sky = $poll->sky; #new method in 0.13 printf "Reported: %s, Used: %s\n", $sky->reported, $sky->used; printf "PRN: %s\n", join(", ", map {$_->used ? $_->prn : "-".$_->prn} $sky->Satellites); =head1 DESCRIPTION Provides a Perl object interface to the Satellite data structure returned by the GPSD daemon. An example JSON string: {"PRN":15,"el":77,"az":123,"ss":0, "used":false}, =head1 METHODS =head2 class Returns the object class =head2 string Returns the JSON string =head2 parent Return the parent Net::GPSD object =head2 PRN, prn Returns the GPS Satellites Pseudo Random Number Identifier =cut sub PRN {shift->{"PRN"}}; *prn=\&PRN; =head2 used Returns a L true or false object. =cut sub used {shift->{"used"}}; =head2 az, azimuth Returns the azimuth, degrees from true north. =cut sub az {shift->{"az"}}; *azimuth=\&az; =head2 el, elevation Returns the Elevation in degrees. =cut sub el {shift->{"el"}}; *elevation=\⪙ =head2 ss Signal strength in dBHz. Note: C/N0 is dBHz usually, but trimbles can also emit poorly specified Amplitude Measurement Units. =cut sub ss {shift->{"ss"}}; =head1 BUGS Log on RT and Send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L, L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/Return/ERROR.pm0000644000076400007640000000212411542555016017174 0ustar mdavismdavispackage Net::GPSD3::Return::ERROR; use strict; use warnings; use base qw{Net::GPSD3::Return::Unknown}; our $VERSION='0.12'; =head1 NAME Net::GPSD3::Return::ERROR - Net::GPSD3 Return ERROR Object =head1 SYNOPSIS =head1 DESCRIPTION Provides a Perl object interface to the ERROR object returned by the GPSD daemon. =head1 METHODS =head2 class Returns the object class =head2 string Returns the JSON string =head2 parent Return the parent Net::GPSD object =head2 message Textual error message. =cut sub message {shift->{"message"}}; =head1 BUGS Log on RT and Send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L, L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/Return/WATCH.pm0000644000076400007640000000277211543447127017166 0ustar mdavismdavispackage Net::GPSD3::Return::WATCH; use strict; use warnings; use base qw{Net::GPSD3::Return::Unknown}; our $VERSION='0.14'; =head1 NAME Net::GPSD3::Return::WATCH - Net::GPSD3 Return WATCH Object =head1 SYNOPSIS =head1 DESCRIPTION Provides a Perl object interface to the WATCH object returned by the GPSD daemon. =head1 METHODS =head2 class Returns the object class =head2 string Returns the JSON string =head2 parent Return the parent L object =head2 enabled =cut sub enabled { my $self=shift; return $self->{"enable"} || $self->{"enabled"}; #reverse once we move to the new protocol expected 3.5 } =head2 enable (deprecated) =cut sub enable {shift->enabled(@_)}; #bad protocol name =head2 json =cut sub json {shift->{"json"}}; =head2 nmea =cut sub nmea {shift->{"nmea"}}; =head2 raw =cut sub raw {shift->{"raw"}}; =head2 scaled =cut sub scaled {shift->{"scaled"}}; =head2 timing =cut sub timing {shift->{"timing"}}; =head1 BUGS Log on RT and Send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L, L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/Return/GST.pm0000644000076400007640000000444311543453510016743 0ustar mdavismdavispackage Net::GPSD3::Return::GST; use strict; use warnings; use base qw{Net::GPSD3::Return::Unknown::Timestamp}; our $VERSION='0.14'; =head1 NAME Net::GPSD3::Return::GST - Net::GPSD3 Return GST Object =head1 SYNOPSIS =head1 DESCRIPTION Provides a Perl object interface to the GST (GPS Pseudorange Noise Statistics) object returned by the GPSD daemon. { 'class' => 'GST', 'device' => '/dev/cuaU0', 'tag' => '0x0130', 'time' => '1970-01-01T00:00:00.00Z', 'lat' => '0', 'lon' => '0', 'alt' => '0.002', 'rms' => '0', 'orient' => '0', 'major' => '0' 'minor' => '-0', } =head1 METHODS PROPERTIES =head2 class Returns the object class =head2 string Returns the JSON string =head2 parent Returns the parent L object =head2 device =cut sub device {shift->{"device"}}; =head2 tag =cut sub tag {shift->{"tag"}}; =head2 time Returns a unix epoch time =head2 timestamp Returns a W3C formated date =head2 datetime Returns a L object =head2 rms Total RMS standard deviation of ranges inputs to the navigation solution =cut sub rms {shift->{"rms"}}; =head2 major Standard deviation (meters) of semi-major axis of error ellipse =cut sub major {shift->{"major"}}; =head2 minor Standard deviation (meters) of semi-minor axis of error ellipse =cut sub minor {shift->{"minor"}}; =head2 orient Orientation of semi-major axis of error ellipse (true north degrees) =cut sub orient {shift->{"orient"}}; =head2 lat Standard deviation (meters) of latitude error =cut sub lat {shift->{"lat"}}; =head2 lon Standard deviation (meters) of longitude error =cut sub lon {shift->{"lon"}}; =head2 alt Standard deviation (meters) of altitude error =cut sub alt {shift->{"alt"}}; =head1 BUGS Log on RT and Send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L, L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/Return/VERSION.pm0000644000076400007640000000347011543447110017431 0ustar mdavismdavispackage Net::GPSD3::Return::VERSION; use strict; use warnings; use base qw{Net::GPSD3::Return::Unknown}; our $VERSION='0.14'; =head1 NAME Net::GPSD3::Return::VERSION - Net::GPSD3 Return VERSION Object =head1 SYNOPSIS use Net::GPSD3; my $gpsd=Net::GPSD3->new; $gpsd->poll; #Sets VERSION and DEVICES in cache my $v=$gpsd->cache->VERSION; printf "Class: %s\nRelease: %s\nRevision: %s\nProtocol: %s\n", $v->class, $v->release, $v->revision, $v->protocol; Returns something like this. Class: VERSION Release: 2.96~dev Revision: 2011-03-17T02:51:23 Protocol: 3.4 =head1 DESCRIPTION Provides a Perl object interface to the VERSION object returned by the GPSD daemon. =head1 METHODS =head2 class Returns the object class =head2 string Returns the JSON string =head2 parent Return the parent L object =head2 release =cut sub release {shift->{"release"}}; =head2 rev, revision =cut *revision=\&rev; sub rev {shift->{"rev"}}; =head2 proto, protocol =cut *protocol=\&proto; sub proto { my $self=shift; return join(".", $self->proto_major, $self->proto_minor); } =head2 proto_major =cut sub proto_major {shift->{"proto_major"}}; =head2 proto_minor =cut sub proto_minor {shift->{"proto_minor"}}; =head1 BUGS Log on RT and Send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L, L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/Return/POLL.pm0000644000076400007640000000762211677243465017074 0ustar mdavismdavispackage Net::GPSD3::Return::POLL; use strict; use warnings; use base qw{Net::GPSD3::Return::Unknown::Timestamp}; our $VERSION='0.18'; =head1 NAME Net::GPSD3::Return::POLL - Net::GPSD3 Return POLL Object =head1 SYNOPSIS use Net::GPSD3; use Data::Dumper qw{Dumper}; my $gpsd = Net::GPSD3->new; my $poll = $gpsd->poll; print Dumper($poll); =head1 DESCRIPTION Provides a Perl object interface to the POLL object returned by the GPSD daemon. =head1 METHODS =head2 class Returns the object class =head2 string Returns the JSON string =head2 parent Return the parent L object =head2 time =head2 timestamp =head2 datetime =head2 active =cut sub active {shift->{"active"}}; =head2 fix, tpv Returns the first fix from the Fixes array or undef if none. my $fix=$poll->fix #isa Net::GPSD3::Return::TPV or undef Note: I will try to keep this method consistant =cut sub fix {shift->Fixes->[0]}; sub tpv {shift->Fixes->[0]}; =head2 Fixes Object wrapper around JSON data my $fix=$poll->Fixes #isa [] of Net::GPSD3::Return::TPV objects my @fix=$poll->Fixes #isa () of Net::GPSD3::Return::TPV objects Note: I'm not sure why this is an array from the protocol but do not count on this staying the same =cut sub Fixes { my $self=shift; $self->{"Fixes"}=[map {$self->parent->constructor(%$_, string=>$self->parent->encode($_))} $self->_fixes] unless defined $self->{"Fixes"}; return wantarray ? @{$self->{"Fixes"}} : $self->{"Fixes"}; } sub _fixes { my $self=shift; $self->{"fixes"}=delete($self->{"tpv"}) if exists $self->{"tpv"}; #RT 73489 $self->{"fixes"}=[] unless ref($self->{"fixes"}) eq "ARRAY"; return wantarray ? @{$self->{"fixes"}} : $self->{"fixes"}; } =head2 sky Returns the first object from the Skyviews array or undef if none. my $sky=$poll->sky #isa Net::GPSD3::Return::SKY or undef Note: I will try to keep this method consistant =cut sub sky {shift->Skyviews->[0]}; =head2 Skyviews Object wrapper around JSON data my $sky=$poll->Skyviews #isa [] of Net::GPSD3::Return::SKY objects my @sky=$poll->Skyviews #isa () of Net::GPSD3::Return::SKY objects Note: I'm not sure why this is an array from the protocol but do not count on this staying the same =cut sub Skyviews { my $self=shift; $self->{"Skyviews"}=[map {$self->parent->constructor(%$_, string=>$self->parent->encode($_))} $self->_skyviews] unless defined $self->{"Skyviews"}; return wantarray ? @{$self->{"Skyviews"}} : $self->{"Skyviews"}; } sub _skyviews { my $self=shift; $self->{"skyviews"}=delete($self->{"sky"}) if exists $self->{"sky"}; #RT 73489 $self->{"skyviews"}=[] unless ref($self->{"skyviews"}) eq "ARRAY"; return wantarray ? @{$self->{"skyviews"}} : $self->{"skyviews"}; } =head2 Gst Object wrapper around JSON data my $gst=$poll->Gst #isa [] of Net::GPSD3::Return::GST objects my @gst=$poll->Gst #isa () of Net::GPSD3::Return::GST objects Note: I'm not sure why this is an array from the protocol but do not count on this staying the same =cut sub Gst { my $self=shift; $self->{"Gst"}=[map {$self->parent->constructor(%$_, string=>$self->parent->encode($_))} $self->_gst] unless defined $self->{"Gst"}; return wantarray ? @{$self->{"Gst"}} : $self->{"Gst"}; } sub _gst { my $self=shift; $self->{"gst"}=[] unless ref($self->{"gst"}) eq "ARRAY"; return wantarray ? @{$self->{"gst"}} : $self->{"gst"}; } =head1 BUGS Log on RT and send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L, L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/Base.pm0000644000076400007640000000176411543270020015675 0ustar mdavismdavispackage Net::GPSD3::Base; use strict; use warnings; our $VERSION='0.12'; =head1 NAME Net::GPSD3::Base - Net::GPSD3 base object =head1 SYNOPSIS use base qw{Net::GPSD3::Base}; =head1 DESCRIPTION =head1 CONSTRUCTOR =head2 new =cut sub new { my $this = shift(); my $class = ref($this) || $this; my $self = {}; bless $self, $class; $self->initialize(@_); return $self; } =head1 METHODS =head2 initialize =cut sub initialize { my $self=shift; %$self=@_; } =head1 BUGS Log on RT and Send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L =cut 1; Net-GPSD3-0.19/lib/Net/GPSD3/Cache.pm0000644000076400007640000000365411542554413016040 0ustar mdavismdavispackage Net::GPSD3::Cache; use strict; use warnings; use base qw{Net::GPSD3::Base}; our $VERSION='0.12'; =head1 NAME Net::GPSD3::Cache - Net::GPSD3 caching object =head1 SYNOPSIS use Net::GPSD3; my $cache=Net::GPSD3->cache; #isa Net::GPSD3::Cache $cache->add($obj); #obj isa Net::GPSD3::Return::XXX =head1 DESCRIPTION =head1 METHODS =head2 add Adds an object to the cache. =cut sub add { my $self=shift; my $obj=shift; if ($obj->can("class") and $self->can($obj->class)) { $self->{$obj->class}=$obj; } return $self; } =head2 TPV Returns the last L object reported by gpsd. =cut sub TPV {shift->{"TPV"}}; =head2 SKY Returns the last L object reported by gpsd. =cut sub SKY {shift->{"SKY"}}; =head2 DEVICES Returns the last L object reported by gpsd. =cut sub DEVICES {shift->{"DEVICES"}}; =head2 VERSION Returns the last L object reported by gpsd. =cut sub VERSION {shift->{"VERSION"}}; =head2 ERROR Returns the last L object reported by gpsd. =cut sub ERROR {shift->{"ERROR"}}; =head2 WATCH Returns the last L object reported by gpsd. =cut sub WATCH {shift->{"WATCH"}}; =head2 SUBFRAME Returns the last L object reported by gpsd. =cut sub SUBFRAME {shift->{"SUBFRAME"}}; =head1 BUGS Log on RT and Send to gpsd-dev email list =head1 SUPPORT DavisNetworks.com supports all Perl applications including this package. Try gpsd-dev email list =head1 AUTHOR Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ =head1 COPYRIGHT This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. =head1 SEE ALSO L =cut 1;