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

The pps-client.h 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 <math.h>
#include <sys/types.h>
#include <errno.h>
#include <poll.h>
#include <sys/mman.h>
Include dependency graph for pps-client.h:

Go to the source code of this file.

Data Structures

struct  timeCheckParams
 Struct for passing arguments to and from threads querying SNTP time servers or GPS receivers. More...
 
struct  G
 Struct for program-wide global variables showing those important to the controller. More...
 

Macros

#define PTHREAD_STACK_REQUIRED   16384
 Stack space requirements for threads. More...
 
#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)
 Inverse seconds per minute. More...
 
#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 SHOW_INTRPT_DATA_INTVL   6
 The number of seconds between displays of interrupt delay in the PPS-Client status line. More...
 
#define INV_DELAY_SAMPLES_PER_MIN   (1.0 / (double)SECS_PER_MINUTE)
 Constant for calculating G.sysDelay. More...
 
#define FREQDIFF_INTRVL   5
 The number of minutes between Allan deviation samples of system clock frequency correction. More...
 
#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 INTERRUPT_LATENCY   6
 Default interrupt latency assigned to sysDelay (microseconds). More...
 
#define RAW_ERROR_ZERO   20
 Index corresponding to rawError == 0 in detectDelayPeak(). More...
 
#define MIN_PEAK_RATIO   0.05
 Minimum ratio to detect a second peak in detectDelayPeak(). More...
 
#define MAX_VALLEY_RATIO   0.99
 Maximum ratio to detect a valley before the second peak in detectDelayPeak(). 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 SNTP 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   600
 Interval between serial port time checks (about 10 minutes) More...
 
#define MAX_SPIKES   30
 Maximum microseconds to suppress a burst of continuous positive jitter. More...
 
#define NOISE_FACTOR   0.354
 Adjusts G.noiseLevel to track G.sysDelay. 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   65
 Jitter slew value below which the controller will begin to frequency lock. More...
 
#define MAX_LINE_LEN   50
 
#define STRBUF_SZ   500
 
#define LOGBUF_SZ   500
 
#define MSGBUF_SZ   500
 
#define SNTP_MSG_SZ   200
 
#define CONFIG_FILE_SZ   10000
 
#define NUM_PARAMS   5
 
#define ERROR_DISTRIB_LEN   121
 
#define JITTER_DISTRIB_LEN   121
 
#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 HARD_LIMIT_05   0.5
 
#define HIGH   1
 
#define LOW   0
 
#define MAX_CONFIGS   32
 
#define ERROR_DISTRIB   1
 
#define ALERT_PPS_LOST   2
 
#define JITTER_DISTRIB   4
 
#define CALIBRATE   8
 
#define INTERRUPT_DISTRIB   16
 
#define SYSDELAY_DISTRIB   32
 
#define EXIT_LOST_PPS   64
 
#define PPS_GPIO   128
 
#define OUTPUT_GPIO   256
 
#define INTRPT_GPIO   512
 
#define SNTP   1024
 
#define SERIAL   2048
 
#define SERIAL_PORT   4096
 

Detailed Description

The pps-client.h file contains includes, defines and structures for PPS-Client.

Copyright (C) 2016-2018 Raymond S. Connell

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Definition in file pps-client.h.

Macro Definition Documentation

◆ ADJTIMEX_SCALE

#define ADJTIMEX_SCALE   65536.0

Frequency scaling required by adjtimex().

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

◆ ALERT_PPS_LOST

#define ALERT_PPS_LOST   2

Definition at line 111 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 76 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 77 of file pps-client.h.

◆ CALIBRATE

#define CALIBRATE   8

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

◆ CHECK_TIME

#define CHECK_TIME   1024

Interval between Internet time checks (about 17 minutes)

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

◆ CHECK_TIME_SERIAL

#define CHECK_TIME_SERIAL   600

Interval between serial port time checks (about 10 minutes)

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

◆ CONFIG_FILE_SZ

#define CONFIG_FILE_SZ   10000

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

◆ ERROR_DISTRIB

#define ERROR_DISTRIB   1

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

◆ ERROR_DISTRIB_LEN

#define ERROR_DISTRIB_LEN   121

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

◆ EXIT_LOST_PPS

#define EXIT_LOST_PPS   64

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

◆ FIVE_MINUTES

#define FIVE_MINUTES   5

Definition at line 49 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 57 of file pps-client.h.

◆ HARD_LIMIT_05

#define HARD_LIMIT_05   0.5

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

◆ HARD_LIMIT_1

#define HARD_LIMIT_1   1

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

◆ HARD_LIMIT_1024

#define HARD_LIMIT_1024   1024

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

◆ HARD_LIMIT_4

#define HARD_LIMIT_4   4

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

◆ HARD_LIMIT_NONE

#define HARD_LIMIT_NONE   32768

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

◆ HIGH

#define HIGH   1

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

◆ INTEGRAL_GAIN

#define INTEGRAL_GAIN   0.63212

Controller integral gain constant in active controller operation.

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

◆ INTERRUPT_DISTRIB

#define INTERRUPT_DISTRIB   16

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

◆ INTERRUPT_LATENCY

#define INTERRUPT_LATENCY   6

Default interrupt latency assigned to sysDelay (microseconds).

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

◆ INTERRUPT_LOST

#define INTERRUPT_LOST   15

Number of consecutive lost interrupts at which a warning starts.

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

◆ INTRPT_DISTRIB_LEN

#define INTRPT_DISTRIB_LEN   121

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

◆ INTRPT_GPIO

#define INTRPT_GPIO   512

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

◆ INV_DELAY_SAMPLES_PER_MIN

#define INV_DELAY_SAMPLES_PER_MIN   (1.0 / (double)SECS_PER_MINUTE)

Constant for calculating G.sysDelay.

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

◆ INV_GAIN_0

#define INV_GAIN_0   4

Controller inverse proportional gain constant at startup.

Definition at line 53 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 52 of file pps-client.h.

◆ JITTER_DISTRIB

#define JITTER_DISTRIB   4

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

◆ JITTER_DISTRIB_LEN

#define JITTER_DISTRIB_LEN   121

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

◆ LOGBUF_SZ

#define LOGBUF_SZ   500

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

◆ LOW

#define LOW   0

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

◆ MAX_CONFIGS

#define MAX_CONFIGS   32

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

◆ MAX_LINE_LEN

#define MAX_LINE_LEN   50

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

◆ MAX_SERVERS

#define MAX_SERVERS   4

Maximum number of SNTP time servers to use.

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

◆ MAX_SPIKES

#define MAX_SPIKES   30

Maximum microseconds to suppress a burst of continuous positive jitter.

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

◆ MAX_VALLEY_RATIO

#define MAX_VALLEY_RATIO   0.99

Maximum ratio to detect a valley before the second peak in detectDelayPeak().

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

◆ MIN_PEAK_RATIO

#define MIN_PEAK_RATIO   0.05

Minimum ratio to detect a second peak in detectDelayPeak().

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

◆ MSGBUF_SZ

#define MSGBUF_SZ   500

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

◆ NOISE_FACTOR

#define NOISE_FACTOR   0.354

Adjusts G.noiseLevel to track G.sysDelay.

Definition at line 82 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 83 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 48 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 60 of file pps-client.h.

◆ NUM_PARAMS

#define NUM_PARAMS   5

Definition at line 94 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 59 of file pps-client.h.

◆ OUTPUT_GPIO

#define OUTPUT_GPIO   256

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

◆ PER_MINUTE

#define PER_MINUTE   (1.0 / (double)SECS_PER_MINUTE)

Inverse seconds per minute.

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

◆ PER_NUM_INTEGRALS

#define PER_NUM_INTEGRALS   (1.0 / (double)NUM_INTEGRALS)

Inverse of NUM_INTEGRALS.

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

◆ PPS_GPIO

#define PPS_GPIO   128

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

◆ PTHREAD_STACK_REQUIRED

#define PTHREAD_STACK_REQUIRED   16384

Stack space requirements for threads.

Definition at line 41 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 70 of file pps-client.h.

◆ RAW_ERROR_ZERO

#define RAW_ERROR_ZERO   20

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

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

◆ SECS_PER_10_MIN

#define SECS_PER_10_MIN   600

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

◆ SECS_PER_5_MIN

#define SECS_PER_5_MIN   300

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

◆ SECS_PER_DAY

#define SECS_PER_DAY   86400

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

◆ SECS_PER_HOUR

#define SECS_PER_HOUR   3600

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

◆ SECS_PER_MINUTE

#define SECS_PER_MINUTE   60

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

◆ SERIAL

#define SERIAL   2048

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

◆ SERIAL_PORT

#define SERIAL_PORT   4096

Definition at line 122 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 51 of file pps-client.h.

◆ SHOW_INTRPT_DATA_INTVL

#define SHOW_INTRPT_DATA_INTVL   6

The number of seconds between displays of interrupt delay in the PPS-Client status line.

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

◆ SLEW_LEN

#define SLEW_LEN   10

The slew accumulator (slewAccum) update interval.

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

◆ SLEW_MAX

#define SLEW_MAX   65

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

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

◆ SNTP

#define SNTP   1024

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

◆ SNTP_MSG_SZ

#define SNTP_MSG_SZ   200

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

◆ STRBUF_SZ

#define STRBUF_SZ   500

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

◆ SYSDELAY_DISTRIB

#define SYSDELAY_DISTRIB   32

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

◆ USECS_PER_SEC

#define USECS_PER_SEC   1000000

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