PPS-Client  2.0.0
Client for synchronizing the system clock to a GPS PPS source
Classes | Macros
pps-client.h File Reference

This file contains includes, defines and structures for PPS-Client. More...

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/timex.h>
#include <sys/time.h>
#include <math.h>
#include <sys/types.h>
#include <errno.h>
#include <poll.h>
#include <sys/mman.h>
#include "timepps.h"
#include <inttypes.h>
Include dependency graph for pps-client.h:

Go to the source code of this file.

Classes

struct  timeCheckParams
 
struct  G
 Struct for program-wide global variables showing those important to the controller. More...
 

Macros

#define USECS_PER_SEC   1000000
 
#define SECS_PER_MINUTE   60
 
#define SECS_PER_5_MIN   300
 
#define SECS_PER_10_MIN   600
 
#define SECS_PER_HOUR   3600
 
#define SECS_PER_DAY   86400
 
#define NUM_5_MIN_INTERVALS   288
 Number of five minute intervals in 24 hours. More...
 
#define FIVE_MINUTES   5
 
#define PER_MINUTE   (1.0 / (double)SECS_PER_MINUTE)
 
#define SETTLE_TIME   (2 * SECS_PER_10_MIN)
 The PPS-Client up time required before saving performance data. More...
 
#define INV_GAIN_1   1
 Controller inverse proportional gain constant during active controller operation. More...
 
#define INV_GAIN_0   4
 Controller inverse proportional gain constant at startup. More...
 
#define INTEGRAL_GAIN   0.63212
 Controller integral gain constant in active controller operation. More...
 
#define FREQDIFF_INTRVL   5
 The number of minutes between Allan deviation samples of system clock frequency correction. More...
 
#define PPS_WINDOW   500
 WaitForPPS delay loop time window in which to look for a PPS. More...
 
#define PTHREAD_STACK_REQUIRED   16384
 Stack space requirements for threads. More...
 
#define ZERO_OFFSET_RPI3   8
 
#define ZERO_OFFSET_RPI4   4
 
#define OFFSETFIFO_LEN   80
 Length of G.correctionFifo which contains the data used to generate G.avgCorrection. More...
 
#define NUM_INTEGRALS   10
 Number of integrals used by makeAverageIntegral() to calculate the one minute clock frequency correction. More...
 
#define PER_NUM_INTEGRALS   (1.0 / (double)NUM_INTEGRALS)
 Inverse of NUM_INTEGRALS. More...
 
#define ADJTIMEX_SCALE   65536.0
 Frequency scaling required by adjtimex(). More...
 
#define RAW_ERROR_ZERO   20
 Index corresponding to rawError == 0 in buildRawErrorDistrib(). More...
 
#define RAW_ERROR_DECAY   0.98851
 Decay rate for G.rawError samples (1 hour half life) More...
 
#define INTERRUPT_LOST   15
 Number of consecutive lost interrupts at which a warning starts. More...
 
#define MAX_SERVERS   4
 Maximum number of NIST time servers to use. More...
 
#define CHECK_TIME   1024
 Interval between Internet time checks (about 17 minutes) More...
 
#define BLOCK_FOR_10   10
 Blocks detection of external system clock changes for 10 seconds. More...
 
#define BLOCK_FOR_3   3
 Blocks detection of external system clock changes for 3 seconds. More...
 
#define CHECK_TIME_SERIAL   10
 Interval between serial port time checks (10 seconds) More...
 
#define MAX_SPIKES   60
 Maximum microseconds to suppress a burst of continuous positive jitter. More...
 
#define MAX_SPIKE_LEVEL   1000000
 An initialization value for G.minSustainedDelay. More...
 
#define CLK_CHANGED_LEVEL   1000
 
#define LARGE_SPIKE   80
 Level above which spikes are are disruptive. More...
 
#define NOISE_ACCUM_RATE   0.1
 Sets the rate at which G.noiseLevel adjusts to G.rawError. More...
 
#define NOISE_LEVEL_MIN   4
 The minimum level at which interrupt delays are delay spikes. More...
 
#define SLEW_LEN   10
 The slew accumulator (slewAccum) update interval. More...
 
#define SLEW_MAX   300
 Jitter slew value below which the controller will begin to frequency lock. More...
 
#define MAX_LINE_LEN   50
 
#define STRBUF_SZ   1000
 
#define LOGBUF_SZ   1000
 
#define MSGBUF_SZ   1000
 
#define NIST_MSG_SZ   200
 
#define CONFIG_FILE_SZ   10000
 
#define NUM_PARAMS   5
 
#define ERROR_DISTRIB_LEN   121
 
#define JITTER_DISTRIB_LEN   181
 
#define INTRPT_DISTRIB_LEN   121
 
#define HARD_LIMIT_NONE   32768
 
#define HARD_LIMIT_1024   1024
 
#define HARD_LIMIT_4   4
 
#define HARD_LIMIT_1   1
 
#define HIGH   1
 
#define LOW   0
 
#define MAX_CONFIGS   32
 
#define ERROR_DISTRIB   1
 
#define ALERT_PPS_LOST   2
 
#define JITTER_DISTRIB   4
 
#define EXIT_LOST_PPS   8
 
#define PPS_GPIO   16
 
#define OUTPUT_GPIO   32
 
#define INTRPT_GPIO   64
 
#define NIST   128
 
#define SERIAL   256
 
#define SERIAL_PORT   512
 
#define EXECDIR   1024
 
#define SERVICEDIR   2048
 
#define CONFIGDIR   4096
 
#define DOCDIR   8192
 
#define RUNDIR   16384
 
#define SHMDIR   32768
 
#define TSTDIR   65536
 
#define LOGDIR   131072
 
#define PPSDELAY   262144
 
#define MODULEDIR   524288
 
#define PPSDEVICE   1048576
 
#define PPSPHASE   2097152
 
#define PROCDIR   4194304
 
#define SEGREGATE   8388608
 

Detailed Description

This file contains includes, defines and structures for PPS-Client.

v2.0.0 updated on 27 Mar 2020

Definition in file pps-client.h.

Macro Definition Documentation

◆ ADJTIMEX_SCALE

#define ADJTIMEX_SCALE   65536.0

Frequency scaling required by adjtimex().

Definition at line 72 of file pps-client.h.

◆ ALERT_PPS_LOST

#define ALERT_PPS_LOST   2

Definition at line 118 of file pps-client.h.

◆ BLOCK_FOR_10

#define BLOCK_FOR_10   10

Blocks detection of external system clock changes for 10 seconds.

Definition at line 81 of file pps-client.h.

◆ BLOCK_FOR_3

#define BLOCK_FOR_3   3

Blocks detection of external system clock changes for 3 seconds.

Definition at line 82 of file pps-client.h.

◆ CHECK_TIME

#define CHECK_TIME   1024

Interval between Internet time checks (about 17 minutes)

Definition at line 80 of file pps-client.h.

◆ CHECK_TIME_SERIAL

#define CHECK_TIME_SERIAL   10

Interval between serial port time checks (10 seconds)

Definition at line 83 of file pps-client.h.

◆ CLK_CHANGED_LEVEL

#define CLK_CHANGED_LEVEL   1000

Definition at line 87 of file pps-client.h.

◆ CONFIG_FILE_SZ

#define CONFIG_FILE_SZ   10000

Definition at line 100 of file pps-client.h.

◆ CONFIGDIR

#define CONFIGDIR   4096

Definition at line 129 of file pps-client.h.

◆ DOCDIR

#define DOCDIR   8192

Definition at line 130 of file pps-client.h.

◆ ERROR_DISTRIB

#define ERROR_DISTRIB   1

Definition at line 117 of file pps-client.h.

◆ ERROR_DISTRIB_LEN

#define ERROR_DISTRIB_LEN   121

Definition at line 103 of file pps-client.h.

◆ EXECDIR

#define EXECDIR   1024

Definition at line 127 of file pps-client.h.

◆ EXIT_LOST_PPS

#define EXIT_LOST_PPS   8

Definition at line 120 of file pps-client.h.

◆ FIVE_MINUTES

#define FIVE_MINUTES   5

Definition at line 55 of file pps-client.h.

◆ FREQDIFF_INTRVL

#define FREQDIFF_INTRVL   5

The number of minutes between Allan deviation samples of system clock frequency correction.

Definition at line 61 of file pps-client.h.

◆ HARD_LIMIT_1

#define HARD_LIMIT_1   1

Definition at line 110 of file pps-client.h.

◆ HARD_LIMIT_1024

#define HARD_LIMIT_1024   1024

Definition at line 108 of file pps-client.h.

◆ HARD_LIMIT_4

#define HARD_LIMIT_4   4

Definition at line 109 of file pps-client.h.

◆ HARD_LIMIT_NONE

#define HARD_LIMIT_NONE   32768

Definition at line 107 of file pps-client.h.

◆ HIGH

#define HIGH   1

Definition at line 112 of file pps-client.h.

◆ INTEGRAL_GAIN

#define INTEGRAL_GAIN   0.63212

Controller integral gain constant in active controller operation.

Definition at line 60 of file pps-client.h.

◆ INTERRUPT_LOST

#define INTERRUPT_LOST   15

Number of consecutive lost interrupts at which a warning starts.

Definition at line 77 of file pps-client.h.

◆ INTRPT_DISTRIB_LEN

#define INTRPT_DISTRIB_LEN   121

Definition at line 105 of file pps-client.h.

◆ INTRPT_GPIO

#define INTRPT_GPIO   64

Definition at line 123 of file pps-client.h.

◆ INV_GAIN_0

#define INV_GAIN_0   4

Controller inverse proportional gain constant at startup.

Definition at line 59 of file pps-client.h.

◆ INV_GAIN_1

#define INV_GAIN_1   1

Controller inverse proportional gain constant during active controller operation.

Definition at line 58 of file pps-client.h.

◆ JITTER_DISTRIB

#define JITTER_DISTRIB   4

Definition at line 119 of file pps-client.h.

◆ JITTER_DISTRIB_LEN

#define JITTER_DISTRIB_LEN   181

Definition at line 104 of file pps-client.h.

◆ LARGE_SPIKE

#define LARGE_SPIKE   80

Level above which spikes are are disruptive.

Definition at line 89 of file pps-client.h.

◆ LOGBUF_SZ

#define LOGBUF_SZ   1000

Definition at line 97 of file pps-client.h.

◆ LOGDIR

#define LOGDIR   131072

Definition at line 134 of file pps-client.h.

◆ LOW

#define LOW   0

Definition at line 113 of file pps-client.h.

◆ MAX_CONFIGS

#define MAX_CONFIGS   32

Definition at line 115 of file pps-client.h.

◆ MAX_LINE_LEN

#define MAX_LINE_LEN   50

Definition at line 95 of file pps-client.h.

◆ MAX_SERVERS

#define MAX_SERVERS   4

Maximum number of NIST time servers to use.

Definition at line 79 of file pps-client.h.

◆ MAX_SPIKE_LEVEL

#define MAX_SPIKE_LEVEL   1000000

An initialization value for G.minSustainedDelay.

Definition at line 86 of file pps-client.h.

◆ MAX_SPIKES

#define MAX_SPIKES   60

Maximum microseconds to suppress a burst of continuous positive jitter.

Definition at line 85 of file pps-client.h.

◆ MODULEDIR

#define MODULEDIR   524288

Definition at line 136 of file pps-client.h.

◆ MSGBUF_SZ

#define MSGBUF_SZ   1000

Definition at line 98 of file pps-client.h.

◆ NIST

#define NIST   128

Definition at line 124 of file pps-client.h.

◆ NIST_MSG_SZ

#define NIST_MSG_SZ   200

Definition at line 99 of file pps-client.h.

◆ NOISE_ACCUM_RATE

#define NOISE_ACCUM_RATE   0.1

Sets the rate at which G.noiseLevel adjusts to G.rawError.

Definition at line 90 of file pps-client.h.

◆ NOISE_LEVEL_MIN

#define NOISE_LEVEL_MIN   4

The minimum level at which interrupt delays are delay spikes.

Definition at line 91 of file pps-client.h.

◆ NUM_5_MIN_INTERVALS

#define NUM_5_MIN_INTERVALS   288

Number of five minute intervals in 24 hours.

Definition at line 54 of file pps-client.h.

◆ NUM_INTEGRALS

#define NUM_INTEGRALS   10

Number of integrals used by makeAverageIntegral() to calculate the one minute clock frequency correction.

Definition at line 69 of file pps-client.h.

◆ NUM_PARAMS

#define NUM_PARAMS   5

Definition at line 102 of file pps-client.h.

◆ OFFSETFIFO_LEN

#define OFFSETFIFO_LEN   80

Length of G.correctionFifo which contains the data used to generate G.avgCorrection.

Definition at line 68 of file pps-client.h.

◆ OUTPUT_GPIO

#define OUTPUT_GPIO   32

Definition at line 122 of file pps-client.h.

◆ PER_MINUTE

#define PER_MINUTE   (1.0 / (double)SECS_PER_MINUTE)

Definition at line 56 of file pps-client.h.

◆ PER_NUM_INTEGRALS

#define PER_NUM_INTEGRALS   (1.0 / (double)NUM_INTEGRALS)

Inverse of NUM_INTEGRALS.

Definition at line 70 of file pps-client.h.

◆ PPS_GPIO

#define PPS_GPIO   16

Definition at line 121 of file pps-client.h.

◆ PPS_WINDOW

#define PPS_WINDOW   500

WaitForPPS delay loop time window in which to look for a PPS.

Definition at line 62 of file pps-client.h.

◆ PPSDELAY

#define PPSDELAY   262144

Definition at line 135 of file pps-client.h.

◆ PPSDEVICE

#define PPSDEVICE   1048576

Definition at line 137 of file pps-client.h.

◆ PPSPHASE

#define PPSPHASE   2097152

Definition at line 138 of file pps-client.h.

◆ PROCDIR

#define PROCDIR   4194304

Definition at line 139 of file pps-client.h.

◆ PTHREAD_STACK_REQUIRED

#define PTHREAD_STACK_REQUIRED   16384

Stack space requirements for threads.

Definition at line 63 of file pps-client.h.

◆ RAW_ERROR_DECAY

#define RAW_ERROR_DECAY   0.98851

Decay rate for G.rawError samples (1 hour half life)

Definition at line 75 of file pps-client.h.

◆ RAW_ERROR_ZERO

#define RAW_ERROR_ZERO   20

Index corresponding to rawError == 0 in buildRawErrorDistrib().

Definition at line 74 of file pps-client.h.

◆ RUNDIR

#define RUNDIR   16384

Definition at line 131 of file pps-client.h.

◆ SECS_PER_10_MIN

#define SECS_PER_10_MIN   600

Definition at line 51 of file pps-client.h.

◆ SECS_PER_5_MIN

#define SECS_PER_5_MIN   300

Definition at line 50 of file pps-client.h.

◆ SECS_PER_DAY

#define SECS_PER_DAY   86400

Definition at line 53 of file pps-client.h.

◆ SECS_PER_HOUR

#define SECS_PER_HOUR   3600

Definition at line 52 of file pps-client.h.

◆ SECS_PER_MINUTE

#define SECS_PER_MINUTE   60

Definition at line 49 of file pps-client.h.

◆ SEGREGATE

#define SEGREGATE   8388608

Definition at line 140 of file pps-client.h.

◆ SERIAL

#define SERIAL   256

Definition at line 125 of file pps-client.h.

◆ SERIAL_PORT

#define SERIAL_PORT   512

Definition at line 126 of file pps-client.h.

◆ SERVICEDIR

#define SERVICEDIR   2048

Definition at line 128 of file pps-client.h.

◆ SETTLE_TIME

#define SETTLE_TIME   (2 * SECS_PER_10_MIN)

The PPS-Client up time required before saving performance data.

Definition at line 57 of file pps-client.h.

◆ SHMDIR

#define SHMDIR   32768

Definition at line 132 of file pps-client.h.

◆ SLEW_LEN

#define SLEW_LEN   10

The slew accumulator (slewAccum) update interval.

Definition at line 92 of file pps-client.h.

◆ SLEW_MAX

#define SLEW_MAX   300

Jitter slew value below which the controller will begin to frequency lock.

Definition at line 93 of file pps-client.h.

◆ STRBUF_SZ

#define STRBUF_SZ   1000

Definition at line 96 of file pps-client.h.

◆ TSTDIR

#define TSTDIR   65536

Definition at line 133 of file pps-client.h.

◆ USECS_PER_SEC

#define USECS_PER_SEC   1000000

Definition at line 48 of file pps-client.h.

◆ ZERO_OFFSET_RPI3

#define ZERO_OFFSET_RPI3   8

Definition at line 65 of file pps-client.h.

◆ ZERO_OFFSET_RPI4

#define ZERO_OFFSET_RPI4   4

Definition at line 66 of file pps-client.h.