diff options
-rw-r--r-- | ppsthread.c | 13 | ||||
-rw-r--r-- | ppsthread.h | 18 |
2 files changed, 18 insertions, 13 deletions
diff --git a/ppsthread.c b/ppsthread.c index 331491b9..21dd6628 100644 --- a/ppsthread.c +++ b/ppsthread.c @@ -28,11 +28,14 @@ * Note that for easy debugging all logging from this file is prefixed * with PPS or KPPS. * - * To use the thread manager, you need to first fill in the two - * thread_* methods in the session structure and/or the pps_hook in - * the context structure. Then you can call pps_thread_activate() and - * the thread will launch. It is OK to do this before the device is - * open, the thread will wait on that. + * To use the thread manager, you need to first fill in the + * devicefd, devicename, and the four hook function members in the thread + * context structure. The void *context member is available for your hook + * functions to use; the thread-monitor code doesn't touch it. + * + * After this setup, you can call pps_thread_activate() and the + * thread will launch. It is OK to do this before the device is open, + * the thread will wait on that. * * WARNING! Loss of precision * UNIX time to nanoSec precision is 62 significant bits diff --git a/ppsthread.h b/ppsthread.h index 167a183c..656be6cd 100644 --- a/ppsthread.h +++ b/ppsthread.h @@ -37,20 +37,22 @@ struct timedelta_t { #define timespec_diff_ns(x, y) (long)(((x).tv_sec-(y).tv_sec)*1000000000+(x).tv_nsec-(y).tv_nsec) struct pps_thread_t { - struct timedelta_t fixin; /* real & clock time when in-band fix received */ -#if defined(HAVE_SYS_TIMEPPS_H) - pps_handle_t kernelpps_handle; -#endif /* defined(HAVE_SYS_TIMEPPS_H) */ - int devicefd; /* device file descriptor */ + void *context; + int devicefd; /* device file descriptor */ char *devicename; /*@null@*/ char *(*report_hook)(volatile struct pps_thread_t *, struct timedelta_t *); + /*@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, ...); /*@null@*/ void (*wrap_hook)(volatile struct pps_thread_t *); + struct timedelta_t fixin; /* real & clock time when in-band fix received */ +#if defined(HAVE_SYS_TIMEPPS_H) + pps_handle_t kernelpps_handle; +#endif /* defined(HAVE_SYS_TIMEPPS_H) */ 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 |