blob: ea83d04f477aa2a99d4245043f17d62a2f745e04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*
* This file is Copyright (c) 2015 by the GPSD project
* BSD terms apply: see the file COPYING in the distribution root for details.
*/
#ifndef PPSTHREAD_H
#define PPSTHREAD_H
/* use RFC 2782 PPS API */
/* this needs linux >= 2.6.34 and
* CONFIG_PPS=y
* CONFIG_PPS_DEBUG=y [optional to kernel log pulses]
* CONFIG_PPS_CLIENT_LDISC=y
*/
#ifndef S_SPLINT_S
#if defined(HAVE_SYS_TIMEPPS_H)
// include unistd.h here as it is missing on older pps-tools releases.
// 'close' is not defined otherwise.
#include <unistd.h>
#include <sys/time.h>
#include <sys/timepps.h>
#endif
#endif /* S_SPLINT_S */
struct pps_thread_t {
timestamp_t fixin_real;
struct timespec fixin_clock; /* system clock time when last fix received */
#if defined(HAVE_SYS_TIMEPPS_H)
pps_handle_t kernelpps_handle;
#endif /* defined(HAVE_SYS_TIMEPPS_H) */
int devicefd; /* device file descriptor */
char *devicename;
int chronyfd; /* for talking to chrony */
/*@null@*/ char *(*report_hook)(volatile struct pps_thread_t *,
struct timedelta_t *);
/*@null@*/ void (*wrap_hook)(volatile struct pps_thread_t *);
struct timedelta_t ppsout_last;
int ppsout_count;
/*@null@*/ void (*pps_hook)(volatile struct pps_thread_t *, struct timedelta_t *);
/*@null@*/ void (*log_hook)(volatile struct pps_thread_t *, int errlevel, const char *fmt, ...);
void *context;
};
#define THREAD_ERROR 0
#define THREAD_WARN 1
#define THREAD_INF 2
#define THREAD_PROG 3
#define THREAD_RAW 4
extern void pps_thread_activate(volatile struct pps_thread_t *);
extern void pps_thread_deactivate(volatile struct pps_thread_t *);
extern void pps_thread_stash_fixtime(volatile struct pps_thread_t *,
timestamp_t, struct timespec);
extern int pps_thread_lastpps(volatile struct pps_thread_t *,
struct timedelta_t *);
#endif /* PPSTHREAD_H */
|