update to 3.11

This commit is contained in:
Miroslav Lichvar 2014-08-25 10:57:45 +02:00
parent fcaaed9b58
commit 1c437f3e86
5 changed files with 68 additions and 172 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@
/gpsd-3.10.tar.gz
/gpsd-20140127gitf2753b.tar.gz
/gpsd-20140524gitd6b65b.tar.gz
/gpsd-3.11.tar.gz

View File

@ -1,140 +0,0 @@
commit f2357b3fbf3b242f3998d2ce6b5e1ecce1f65125
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date: Tue May 27 18:08:19 2014 +0200
Fix PPS with large offsets.
This was broken by commit 575444. The check if the PPS time isn't
referenced with an old message time used PPS offset instead of the
difference between local PPS time and local time of the last message.
The PPS sample was reported via SHM or chrony socket only if the offset
was between -1 and 1000001 seconds.
Keep the local timestamp of the last fix in struct gps_device_t in
addition to the real timestamp and use it to check the PPS delay.
Rename the l_offset variable to delay to avoid further confusion.
diff --git a/gpsd.c b/gpsd.c
index 53d68d1..ffaf680 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1557,7 +1557,7 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed)
//gpsd_report(context.debug, LOG_PROG, "NTP: No time this packet\n");
} else if (isnan(device->newdata.time)) {
//gpsd_report(context.debug, LOG_PROG, "NTP: bad new time\n");
- } else if (device->newdata.time == device->last_fixtime) {
+ } else if (device->newdata.time == device->last_fixtime.real) {
//gpsd_report(context.debug, LOG_PROG, "NTP: Not a new time\n");
} else if (!device->ship_to_ntpd) {
//gpsd_report(context.debug, LOG_PROG, "NTP: No precision time report\n");
@@ -1588,7 +1588,8 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed)
/*@-compdef@*/
(void)ntpshm_put(device, device->shmIndex, &td);
/*@+compdef@*/
- device->last_fixtime = device->newdata.time;
+ device->last_fixtime.real = device->newdata.time;
+ device->last_fixtime.clock = td.clock.tv_sec + td.clock.tv_nsec / 1e9;
}
#endif /* NTPSHM_ENABLE */
diff --git a/gpsd.h-tail b/gpsd.h-tail
index 8040094..08e0d59 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -475,7 +475,10 @@ struct gps_device_t {
int shmIndexPPS;
# endif /* PPS_ENABLE */
#endif /* NTPSHM_ENABLE */
- volatile timestamp_t last_fixtime; /* so updates happen once */
+ volatile struct {
+ timestamp_t real;
+ timestamp_t clock;
+ } last_fixtime; /* so updates happen once */
#ifdef PPS_ENABLE
#if defined(HAVE_SYS_TIMEPPS_H)
pps_handle_t kernelpps_handle;
diff --git a/gpsmon.c b/gpsmon.c
index b030979..77b6558 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -770,7 +770,7 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED)
report_unlock();
/* Update the last fix time seen for PPS. FIXME: do this here? */
- device->last_fixtime = device->newdata.time;
+ device->last_fixtime.real = device->newdata.time;
}
/*@+observertrans +nullpass +globstate +compdef +uniondef@*/
diff --git a/ppsthread.c b/ppsthread.c
index d9e431e..ed5c7ef 100644
--- a/ppsthread.c
+++ b/ppsthread.c
@@ -238,7 +238,7 @@ static int init_kernel_pps(struct gps_device_t *session)
static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
{
struct gps_device_t *session = (struct gps_device_t *)arg;
- double last_fixtime = 0;
+ double last_fixtime_real = 0, last_fixtime_clock = 0;
#ifndef HAVE_CLOCK_GETTIME
struct timeval clock_tv = {0, 0};
#endif /* HAVE_CLOCK_GETTIME */
@@ -299,7 +299,8 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
break;
}
/* quick, grab a copy of last_fixtime before it changes */
- last_fixtime = session->last_fixtime;
+ last_fixtime_real = session->last_fixtime.real;
+ last_fixtime_clock = session->last_fixtime.clock;
/*@-noeffect@*/
/* get the time after we just woke up */
@@ -541,7 +542,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
log = "Too long for 0.5Hz\n";
}
#endif /* TIOCMIWAIT */
- if ( ok && last_second_used >= last_fixtime ) {
+ if ( ok && last_second_used >= last_fixtime_real ) {
/* uh, oh, this second already handled */
ok = 0;
log = "this second already handled\n";
@@ -550,7 +551,8 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
if (ok) {
/* offset is the skew from expected to observed pulse time */
double offset;
- long l_offset;
+ /* delay after last fix */
+ double delay;
char *log1 = NULL;
/* drift.real is the time we think the pulse represents */
struct timedrift_t drift;
@@ -580,7 +582,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
*/
/*@+relaxtypes@*/
- drift.real.tv_sec = last_fixtime + 1;
+ drift.real.tv_sec = last_fixtime_real + 1;
drift.real.tv_nsec = 0; /* need to be fixed for 5Hz */
drift.clock = clock_ts;
/*@-relaxtypes@*/
@@ -589,15 +591,15 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg)
* GPS serial input then use that */
offset = (drift.real.tv_sec - drift.clock.tv_sec);
offset += ((drift.real.tv_nsec - drift.clock.tv_nsec) / 1e9);
- l_offset = (long) offset;
- if (0 > l_offset || 1000000 < l_offset) {
+ delay = (drift.clock.tv_sec + drift.clock.tv_nsec / 1e9) - last_fixtime_clock;
+ if (0.0 > delay || 1.0 < delay) {
gpsd_report(session->context->debug, LOG_RAW,
- "PPS: no current GPS seconds: %ld\n",
- (long)l_offset);
+ "PPS: no current GPS seconds: %f\n",
+ delay);
log1 = "timestamp out of range";
} else {
/*@-compdef@*/
- last_second_used = last_fixtime;
+ last_second_used = last_fixtime_real;
if (session->thread_report_hook != NULL)
log1 = session->thread_report_hook(session, &drift);
else

50
gpsd-systemd.patch Normal file
View File

@ -0,0 +1,50 @@
From 86a8f7ecbb7040236602ffb08711ef87bcdb74f7 Mon Sep 17 00:00:00 2001
From: Miroslav Lichvar <mlichvar@redhat.com>
Date: Mon, 25 Aug 2014 11:52:59 +0200
Subject: [PATCH] Update systemd files.
- use $OPTIONS and include /etc/sysconfig/gpsd to make it compatible
with current Fedora packaging
- start gpsd after chronyd service to allow connecting to SOCK
- allow enabling gpsd as a normal service not requiring socket
activation
---
systemd/gpsd.service | 5 ++++-
systemd/gpsdctl@.service | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/systemd/gpsd.service b/systemd/gpsd.service
index ef760a1..ad4be79 100644
--- a/systemd/gpsd.service
+++ b/systemd/gpsd.service
@@ -1,11 +1,14 @@
[Unit]
Description=GPS (Global Positioning System) Daemon
Requires=gpsd.socket
+# Needed with chrony SOCK refclock
+After=chronyd.service
[Service]
EnvironmentFile=-/etc/default/gpsd
EnvironmentFile=-/etc/sysconfig/gpsd
-ExecStart=/usr/sbin/gpsd -N $GPSD_OPTIONS $DEVICES
+ExecStart=/usr/sbin/gpsd -N $GPSD_OPTIONS $OPTIONS $DEVICES
[Install]
+WantedBy=multi-user.target
Also=gpsd.socket
diff --git a/systemd/gpsdctl@.service b/systemd/gpsdctl@.service
index 58c5176..26e49a2 100644
--- a/systemd/gpsdctl@.service
+++ b/systemd/gpsdctl@.service
@@ -8,6 +8,7 @@ After=dev-%i.device
Type=oneshot
Environment="GPSD_SOCKET=/var/run/gpsd.sock"
EnvironmentFile=-/etc/default/gpsd
+EnvironmentFile=-/etc/sysconfig/gpsd
RemainAfterExit=yes
ExecStart=/bin/sh -c "[ \"$USBAUTO\" = true ] && /usr/sbin/gpsdctl add /dev/%I || :"
ExecStop=/bin/sh -c "[ \"$USBAUTO\" = true ] && /usr/sbin/gpsdctl remove /dev/%I || :"
--
1.9.3

View File

@ -1,22 +1,18 @@
%global _hardened_build 1
%global gitrev 20140524gitd6b65b
Name: gpsd
Version: 3.10
Release: 6.%{gitrev}%{?dist}
Version: 3.11
Release: 1%{?dist}
Summary: Service daemon for mediating access to a GPS
Group: System Environment/Daemons
License: BSD
URL: http://catb.org/gpsd/
#Source0: http://download.savannah.gnu.org/releases/gpsd/%{name}-%{version}.tar.gz
Source0: gpsd-%{gitrev}.tar.gz
Source10: gpsd.service
Source0: http://download.savannah.gnu.org/releases/gpsd/%{name}-%{version}.tar.gz
Source11: gpsd.sysconfig
Source12: gpsdctl.service
# Fix PPS with large offsets
Patch1: gpsd-ppsoffset.patch
# Update systemd files
Patch1: gpsd-systemd.patch
BuildRequires: dbus-devel dbus-glib-devel ncurses-devel xmlto python-devel
BuildRequires: scons desktop-file-utils bluez-libs-devel pps-tools-devel
@ -77,15 +73,18 @@ can run on a serial terminal or terminal emulator.
%prep
%setup -q -n %{name}
%patch1 -p1 -b .ppsoffset
%setup -q
%patch1 -p1 -b .systemd
# set gpsd revision string to include package revision
sed -i 's|^revision=.*REVISION.*$|revision='\'\
'#define REVISION "%{version}-%{release}'\"\'\| SConstruct
# fix RPATH
sed -i 's|sysrpath =.*|sysrpath = ["%{_libdir}"]|' SConstruct
# fix systemd path
sed -i 's|systemd_dir =.*|systemd_dir = '\'%{_unitdir}\''|' SConstruct
# don't set RPATH
sed -i 's|env.Prepend.*RPATH.*|pass #\0|' SConstruct
%build
export CCFLAGS="%{optflags}"
@ -106,6 +105,7 @@ scons \
mandir=%{_mandir} \
docdir=%{_docdir} \
pkgconfigdir=%{_libdir}/pkgconfig \
udevdir=$(dirname %{_udevrulesdir}) \
build
@ -113,30 +113,15 @@ scons \
# avoid rebuilding
export CCFLAGS="%{optflags}"
export LINKFLAGS="%{__global_ldflags}"
DESTDIR=%{buildroot} scons install
DESTDIR=%{buildroot} scons install systemd_install udev-install
# service files
%{__install} -d -m 0755 %{buildroot}%{_unitdir}
%{__install} -p -m 0644 %{SOURCE10} \
%{buildroot}%{_unitdir}/gpsd.service
%{__install} -p -m 0644 %{SOURCE12} \
%{buildroot}%{_unitdir}/gpsdctl@.service
%{__install} -p -m 0644 systemd/gpsd.socket \
%{buildroot}%{_unitdir}/gpsd.socket
# use the old name for udev rules
mv %{buildroot}%{_udevrulesdir}/{25,99}-gpsd.rules
%{__install} -d -m 0755 %{buildroot}%{_sysconfdir}/sysconfig
%{__install} -p -m 0644 %{SOURCE11} \
%{buildroot}%{_sysconfdir}/sysconfig/gpsd
# udev rules
%{__install} -d -m 0755 %{buildroot}%{_udevrulesdir}
%{__install} -p -m 0644 gpsd.rules \
%{buildroot}%{_udevrulesdir}/99-gpsd.rules
# Use gpsdctl service instead of hotplug script
sed -i 's|RUN+="/lib/udev/gpsd.hotplug"|TAG+="systemd", ENV{SYSTEMD_WANTS}="gpsdctl@%k.service"|' \
%{buildroot}%{_udevrulesdir}/99-gpsd.rules
# Install the .desktop files
desktop-file-install \
--dir %{buildroot}%{_datadir}/applications \

View File

@ -1 +1 @@
4c358386ebbfdb1629a3ffaabce4a1b7 gpsd-20140524gitd6b65b.tar.gz
ba28369992886fccb85ce560e4727e20 gpsd-3.11.tar.gz