#!/usr/bin/perl
use strict;
use GPS::gpsd;
my $host = shift() || 'localhost';

my $gps=GPS::gpsd->new(host=>$host) || die("Error: Cannot connect to the gpsd server");

print join("|", qw{status datetime . lat lon alt speed heading}), "\n";
foreach (0..5) {
  my $p=$gps->get();
  if ($p->fix) {
    print join("|", $p->status,
                     $p->datetime,
                     $p->lat,
                     $p->lon,
                     $p->alt,
                     $p->speed,
                     $p->heading),
                     "\n";
  } else {
    print "No fix\n";
  }
  sleep 1;
}
