PPS-Client  1.4.0
Client for synchronizing the system clock to a GPS PPS source
Data Structures | Functions | Variables
pps-files.cpp File Reference

The pps-files.cpp file contains functions and structures for saving files intended for PPS-Client status monitoring and analysis. More...

#include "../client/pps-client.h"
Include dependency graph for pps-files.cpp:

Go to the source code of this file.

Data Structures

struct  ppsFilesVars
 

Functions

void initFileLocalData (void)
 
int sysCommand (const char *cmd)
 
char * getString (int key)
 
bool hasString (int key, const char *string)
 
bool isEnabled (int key)
 
bool isDisabled (int key)
 
void couldNotOpenMsgTo (char *logbuf, const char *filename)
 
void errorReadingMsgTo (char *logbuf, const char *filename)
 
void writeToLogNoTimestamp (char *logbuf)
 
void writeToLog (char *logbuf)
 
void bufferStatusMsg (const char *msg)
 
int writeStatusStrings (void)
 
int read_logerr (int fd, char *buf, int sz, const char *filename)
 
int open_logerr (const char *filename, int flags)
 
int writeFileMsgToLogbuf (const char *filename, char *logbuf)
 
int writeFileMsgToLog (const char *filename)
 
pid_t getChildPID (void)
 
bool ppsIsRunning (void)
 
int createPIDfile (void)
 
bool configHasValue (int config_val, void *value)
 
int getDriverGPIOvals (void)
 
int readConfigFile (void)
 
void writeDistribution (int distrib[], int len, int scaleZero, int count, int *last_epoch, const char *distrib_file, const char *last_distrib_file)
 
void writeMultipleDistrib (int label[], int distrib[][INTRPT_DISTRIB_LEN], int len, int scaleZero, int count, int *last_epoch, const char *distrib_file, const char *last_distrib_file)
 
void writeIntrptDistribFile (void)
 
void writeSysdelayDistribFile (void)
 
void writeJitterDistribFile (void)
 
void writeErrorDistribFile (void)
 
void writeOffsets (const char *filename)
 
void writeFrequencyVars (const char *filename)
 
int saveDoubleArray (double distrib[], const char *filename, int len, int arrayZero)
 
int processWriteRequest (void)
 
int processFiles (void)
 
void writeSysDelay (void)
 
void writeTimestamp (double timestamp)
 
int alignNumbersAfter (const char *token, char *buf, int len)
 
int alignTokens (const char *refToken, int offset, const char *token, char *buf, int len)
 
int bufferStateParams (void)
 
int restartNTP (void)
 
int replaceNTPConfig (const char *fbuf)
 
void removeConfigKeys (const char *key1, const char *key2, char *fbuf)
 
int disableNTP (void)
 
int enableNTP (void)
 
char * copyMajorTo (char *majorPos)
 
char * getLinuxVersion (void)
 
int driver_load (int ppsGPIO, int outputGPIO, int intrptGPIO)
 
void driver_unload ()
 
int getSeqNum (const char *pbuf)
 
void showStatusEachSecond (void)
 
void INThandler (int sig)
 
bool missingArg (int argc, char *argv[], int i)
 
int daemonSaveArray (const char *requestStr, const char *filename)
 
void printAcceptedArgs (void)
 
int parseSaveDataRequest (int argc, char *argv[], const char *requestStr)
 
int accessDaemon (int argc, char *argv[])
 
void buildErrorDistrib (int timeCorrection)
 
void buildJitterDistrib (int rawError)
 
void TERMhandler (int sig)
 
void HUPhandler (int sig)
 
int getDelayIndex (int sysDelay)
 
void buildInterruptDistrib (int intrptDelay)
 
void buildSysDelayDistrib (int sysDelay)
 
void recordFrequencyVars (void)
 
void recordOffsets (int timeCorrection)
 

Variables

struct G g
 Declares the global variables defined in pps-client.h. More...
 
const char * last_distrib_file = "/var/local/pps-error-distrib"
 Stores the completed distribution of offset corrections. More...
 
const char * distrib_file = "/var/local/pps-error-distrib-forming"
 Stores a forming distribution of offset corrections. More...
 
const char * last_jitter_distrib_file = "/var/local/pps-jitter-distrib"
 Stores the completed distribution of offset corrections. More...
 
const char * jitter_distrib_file = "/var/local/pps-jitter-distrib-forming"
 Stores a forming distribution of offset corrections. More...
 
const char * log_file = "/var/log/pps-client.log"
 Stores activity and errors. More...
 
const char * old_log_file = "/var/log/pps-client.old.log"
 Stores activity and errors. More...
 
const char * last_intrpt_distrib_file = "/var/local/pps-intrpt-distrib"
 Stores the completed distribution of offset corrections. More...
 
const char * intrpt_distrib_file = "/var/local/pps-intrpt-distrib-forming"
 Stores a forming distribution of offset corrections. More...
 
const char * sysDelay_distrib_file = "/var/local/pps-sysDelay-distrib-forming"
 Stores a forming distribution of sysDelay values. More...
 
const char * last_sysDelay_distrib_file = "/var/local/pps-sysDelay-distrib"
 Stores a distribution of sysDelay. More...
 
const char * pidFilename = "/var/run/pps-client.pid"
 Stores the PID of PPS-Client. More...
 
const char * config_file = "/etc/pps-client.conf"
 The PPS-Client configuration file. More...
 
const char * ntp_config_file = "/etc/ntp.conf"
 The NTP configuration file. More...
 
const char * ntp_config_bac = "/etc/ntp.conf.bac"
 Backup of the NTP configuration file. More...
 
const char * ntp_config_part = "/etc/ntp.conf.part"
 Temporary filename for an NTP config file during copy. More...
 
const char * sysDelay_file = "/run/shm/pps-sysDelay"
 The current sysDelay value updated each second. More...
 
const char * assert_file = "/run/shm/pps-assert"
 The timestamps of the time corrections each second. More...
 
const char * displayParams_file = "/run/shm/pps-display-params"
 Temporary file storing params for the status display. More...
 
const char * arrayData_file = "/run/shm/pps-save-data"
 Stores a request sent to the PPS-Client daemon. More...
 
const char * space = " "
 
const char * num = "0123456789."
 
const char * version
 Program version 1.4.0 created on 17 Dec 2017. More...
 
const char * valid_config []
 
struct saveFileData arrayData []
 

Detailed Description

The pps-files.cpp file contains functions and structures for saving files intended for PPS-Client status monitoring and analysis.

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-files.cpp.

Function Documentation

◆ accessDaemon()

int accessDaemon ( int  argc,
char *  argv[] 
)

Provides command line access to the PPS-Client daemon.

Checks if program is running. If not, returns -1. If an error occurs returns -2. If the program is running then returns 0 and prints a message to that effect.

Recognizes data save requests (-s) and forwards these to the daemon interface.

If verbose flag (-v) is read then also displays status params of the running program to the terminal.

Parameters
[in]argcSystem command line arg
[in]argvSystem command line arg
Returns
0 on success, else as described.

Definition at line 1989 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ alignNumbersAfter()

int alignNumbersAfter ( const char *  token,
char *  buf,
int  len 
)

Provides formatting for console printf() strings.

Horizontally left-aligns a number following token, ignoring numeric sign, in a buffer generated by sprintf() by padding the buffer with spaces preceding the number to be aligned and returning the adjusted length of the buffer.

Parameters
[in]tokenThe token string preceding the number to be aligned.
[in,out]bufThe buffer containing the token.
[in]lenThe initial length of the buffer.
Returns
Adjusted length of the buffer.

Definition at line 1211 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ alignTokens()

int alignTokens ( const char *  refToken,
int  offset,
const char *  token,
char *  buf,
int  len 
)

Provides formatting for console printf() strings.

Horizontally aligns token by a fixed number of characters from the end of refToken by padding the buffer with spaces at the end of the number following refToken.

Parameters
[in]refTokenThe reference token which is followed by a number having a variable length.
[in]offsetThe number of characters in the adjusted buffer from the end of refToken to the start of token.
[in]tokenThe token to be aligned.
[out]bufThe buffer containing the tokens.
[in]lenthe initial length of the buffer.
Returns
The adjusted length of the buffer.

Definition at line 1252 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bufferStateParams()

int bufferStateParams ( void  )

Records a state params string to a buffer, savebuf, that is saved to a tmpfs memory file by writeStatusStrings() along with other relevant messages recorded during the same second.

Returns
0 on success, else -1 on error.

Definition at line 1291 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bufferStatusMsg()

void bufferStatusMsg ( const char *  msg)

Concatenates msg to a message buffer, savebuf, which is saved to a tmpfs memory file by writeStatusStrings() each second. These messages can be read and displayed to the command line by showStatusEachSecond().

Parameters
[in]msgPointer to the message to be concatenated.

Definition at line 290 of file pps-files.cpp.

Here is the caller graph for this function:

◆ buildErrorDistrib()

void buildErrorDistrib ( int  timeCorrection)

Constructs a distribution of time correction values with zero offset at middle index that can be saved to disk for analysis.

A time correction is the raw time error passed through a hard limitter to remove jitter and then scaled by the proportional gain constant.

Parameters
[in]timeCorrectionThe time correction value to be accumulated to a distribution.

Definition at line 2043 of file pps-files.cpp.

Here is the caller graph for this function:

◆ buildInterruptDistrib()

void buildInterruptDistrib ( int  intrptDelay)

Accumulates a distribution of interrupt delay.

Parameters
[in]intrptDelayThe interrupt delay value returned from the PPS-Client device driver.

Definition at line 2137 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ buildJitterDistrib()

void buildJitterDistrib ( int  rawError)

Constructs a distribution of jitter that can be saved to disk for analysis.

All jitter is collected including delay spikes.

Parameters
[in]rawErrorThe raw error jitter value to save to the distribution.

Definition at line 2067 of file pps-files.cpp.

Here is the caller graph for this function:

◆ buildSysDelayDistrib()

void buildSysDelayDistrib ( int  sysDelay)

Accumulates a distribution of sysDelay that can be saved to disk for analysis.

Parameters
[in]sysDelayThe sysDelay value to be recorded to the distribution.

Definition at line 2161 of file pps-files.cpp.

Here is the caller graph for this function:

◆ configHasValue()

bool configHasValue ( int  config_val,
void *  value 
)

Tests configuration strings from /etc/pps-client.conf for a numeric value and returns it in the value pointer. The numeric value may be either int or double with the value pointer and the presence of a decimal point determining int or double.

Parameters
[in]config_valThe configuration identifier value.
[out]valueThe returned numeric value as int or double.
Returns
"true" if the selected config_str has a numeric value, else "false".

Definition at line 550 of file pps-files.cpp.

Here is the caller graph for this function:

◆ copyMajorTo()

char* copyMajorTo ( char *  majorPos)

Reads the major number assigned to gps-pps-io from "/proc/devices" as a string which is returned in the majorPos char pointer. This value is used to load the hardware driver that PPS-Client requires to load PPS interrupt times.

Parameters
[in,out]majorPosA string possibly containing the major number.
Returns
The major number as a char string if found in the input string, else NULL.

Definition at line 1583 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ couldNotOpenMsgTo()

void couldNotOpenMsgTo ( char *  logbuf,
const char *  filename 
)

Constructs an error message.

Definition at line 191 of file pps-files.cpp.

Here is the caller graph for this function:

◆ createPIDfile()

int createPIDfile ( void  )

Creates a PID file for the PPS-Client daemon.

Returns
The PID.

Definition at line 515 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ daemonSaveArray()

int daemonSaveArray ( const char *  requestStr,
const char *  filename 
)

Transmits a data save request to the PPS-Client daemon via data written to a tmpfs shared memory file.

Parameters
[in]requestStrThe request string.
[in]filenameThe shared memory file to write to.
Returns
0 on success, else -1 on error.

Definition at line 1874 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disableNTP()

int disableNTP ( void  )

Disables NTP control of system time by appending "disable ntp" to the NTP config file and then restarting NTP.

Returns
0 on success, else -1 on error.

Definition at line 1462 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ driver_load()

int driver_load ( int  ppsGPIO,
int  outputGPIO,
int  intrptGPIO 
)

Loads the hardware driver required by PPS-Client which is expected to be available in the file: "/lib/modules/`uname -r`/kernel/drivers/misc/gps-pps-io.ko".

Parameters
[in]ppsGPIOA GPIO number to be assigned to the driver.
[in]outputGPIOA GPIO number to be assigned to the driver.
[in]intrptGPIOA GPIO number to be assigned to the driver.
Returns
0 on success, else -1 on error.

Definition at line 1668 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ driver_unload()

void driver_unload ( )

Unloads the gps-pps-io hardware driver.

Definition at line 1733 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enableNTP()

int enableNTP ( void  )

Enables NTP control of system time by removing "disable ntp" from the NTP config file and then restarting NTP.

Returns
0 on success, else -1 on error.

Definition at line 1527 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ errorReadingMsgTo()

void errorReadingMsgTo ( char *  logbuf,
const char *  filename 
)

Constructs an error message.

Definition at line 202 of file pps-files.cpp.

Here is the caller graph for this function:

◆ getChildPID()

pid_t getChildPID ( void  )

Reads the PID of the child process when the parent process needs to kill it.

Returns
The PID or -1 on error.

Definition at line 447 of file pps-files.cpp.

Here is the call graph for this function:

◆ getDelayIndex()

int getDelayIndex ( int  sysDelay)

Generates an unordered list of unique sysDelay values in the g.delayLabel array and returns the index in the array of any sysDelay value.

Parameters
[in]sysDelayThe value.
Returns
The index of the sysDelay value in the delayLabel array.

Definition at line 2114 of file pps-files.cpp.

Here is the caller graph for this function:

◆ getDriverGPIOvals()

int getDriverGPIOvals ( void  )

Reads PPS-Client driver GPIO number assignments from "/etc/pps-client.conf" and stores them as temporary values in the global variables struct to be passed to the PPS-Client driver when it is loaded.

These values are not persistent.

Returns
0 on success else -1.

Definition at line 575 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLinuxVersion()

char* getLinuxVersion ( void  )

Definition at line 1638 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSeqNum()

int getSeqNum ( const char *  pbuf)

Extracts the sequence number g.seq_num from a char string and returns the value.

Parameters
[in]pbufThe string to search.
Returns
The sequence number.

Definition at line 1747 of file pps-files.cpp.

Here is the caller graph for this function:

◆ getString()

char* getString ( int  key)

Retrieves the string from the config file assigned to the valid_config string with value key.

Parameters
[in]keyThe config key corresponding to a string in the valid_config[] array above.
Returns
The string assigned to the key.

Definition at line 108 of file pps-files.cpp.

Here is the caller graph for this function:

◆ hasString()

bool hasString ( int  key,
const char *  string 
)

Tests configuration strings from /etc/pps-client.conf for the specified string. To avoid searching the config file more than once, the config key is a bit position in g.config_select that is set or not set if the corresponding config string is found in the config file when it is first read. In that case an array g.configVals[], constructed when the config file was read, will contain the string from the config file that followed the valid_config. That string will be g.configVals[log2(key)].

Parameters
[in]keyThe config key corresponding to a string in the valid_config[] array above.
[in]stringThe string that must be matched by the string that follows the config string name from the valid_config[] array.
Returns
"true" if the string in the config file matches arg "string", else "false".

Definition at line 137 of file pps-files.cpp.

Here is the caller graph for this function:

◆ HUPhandler()

void HUPhandler ( int  sig)

Catches the SIGHUP signal, causing it to be ignored.

Parameters
[in]sigThe signal from the system.

Definition at line 2101 of file pps-files.cpp.

Here is the caller graph for this function:

◆ initFileLocalData()

void initFileLocalData ( void  )

Definition at line 85 of file pps-files.cpp.

Here is the caller graph for this function:

◆ INThandler()

void INThandler ( int  sig)

Responds to the ctrl-c key combination by setting the exit_loop flag. This causes an exit from the showStatusEachSecond() function.

Parameters
[in]sigThe signal returned by the system.

Definition at line 1842 of file pps-files.cpp.

Here is the caller graph for this function:

◆ isDisabled()

bool isDisabled ( int  key)

Tests configuration strings from /etc/pps-client.conf for the "disable" keyword.

Parameters
[in]keyThe config key corresponding to a string in the valid_config[] array above.
Returns
"true" if the "disable" keyword is detected, else false.

Definition at line 173 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEnabled()

bool isEnabled ( int  key)

Tests configuration strings from /etc/pps-client.conf for the "enable" keyword.

Parameters
[in]keyThe config key corresponding to a string in the valid_config[] array above.
Returns
"true" if the "enable" keyword is detected, else "false".

Definition at line 159 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ missingArg()

bool missingArg ( int  argc,
char *  argv[],
int  i 
)

Checks for and reports on missing arguments in a command line request.

Parameters
[in]argcSystem command line arg
[in]argvSystem command line arg
[in]iThe number of args.
Returns
"true" if an argument is missing, else "false".

Definition at line 1857 of file pps-files.cpp.

Here is the caller graph for this function:

◆ open_logerr()

int open_logerr ( const char *  filename,
int  flags 
)

Opens a file with error logging and sets standard file permissions for O_CREAT.

Parameters
[in]filenameThe file to open.
[in]flagsThe file open flags.
Returns
The file descriptor.

Definition at line 366 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseSaveDataRequest()

int parseSaveDataRequest ( int  argc,
char *  argv[],
const char *  requestStr 
)

Reads a command line save data request and either forwards the data to the daemon interface or prints entry errors back to the terminal.

Parameters
[in]argcSystem command line arg
[in]argvSystem command line arg
[in]requestStrThe request string.
Returns
0 on success, else -1 on error.

Definition at line 1923 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ppsIsRunning()

bool ppsIsRunning ( void  )

Uses a system call to pidof to see if PPS-Client is running.

Returns
If a PID for pps exists returns "true". Else returns "false".

Definition at line 475 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printAcceptedArgs()

void printAcceptedArgs ( void  )

Prints a list to the terminal of the command line args for saving data that are recognized by PPS-Client.

Definition at line 1904 of file pps-files.cpp.

Here is the caller graph for this function:

◆ processFiles()

int processFiles ( void  )

Processes the files and configuration settings specified by the PPS-Client config file.

Definition at line 1086 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processWriteRequest()

int processWriteRequest ( void  )

From within the daemon, reads the data label and filename of an array to write to disk from a request made from the command line with "pps-client -s [label] <filename>". Then matches the requestStr to the corresponding arrayData which is then passed to a routine that saves the array identified by the data label.

Returns
0 on success else -1 on fail.

Definition at line 1033 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_logerr()

int read_logerr ( int  fd,
char *  buf,
int  sz,
const char *  filename 
)

Reads a file with error logging.

Parameters
[in]fdThe file descriptor.
[out]bufThe buffer to hold the file data.
[in]szThe number of bytes to read.
[in]filenameThe filename of the file being read.
Returns
The number of bytes read.

Definition at line 347 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readConfigFile()

int readConfigFile ( void  )

Reads the PPS-Client config file and sets bits in g.config_select to 1 or 0 corresponding to whether a particular g.configVals appears in the config file. The g.configVals from the file is then copied to fbuf and a pointer to that string is placed in the g.configVals array.

If the g.configVals did not occur in the config file then g.configVals has a NULL char* in the corresponding location.

Returns
0 on success, else -1 on error.

Definition at line 626 of file pps-files.cpp.

Here is the caller graph for this function:

◆ recordFrequencyVars()

void recordFrequencyVars ( void  )

Accumulates the clock frequency offset over the last 5 minutes and records offset difference each minute over the previous 5 minute interval. This function is called once each minute.

The values of offset difference, g.freqOffsetDiff[], are used to calculate the Allan deviation of the clock frequency offset which is determined so that it can be saved to disk. g.freqOffsetSum is used to calculate the average clock frequency offset in each 5 minute interval so that value can also be saved to disk.

Definition at line 2185 of file pps-files.cpp.

Here is the caller graph for this function:

◆ recordOffsets()

void recordOffsets ( int  timeCorrection)

Each second, records the time correction that was applied to the system clock and also records the last clock frequency offset (in parts per million) that was applied to the system clock.

These values are recorded so that they may be saved to disk for analysis.

Parameters
[in]timeCorrectionThe time correction value to be recorded.

Definition at line 2231 of file pps-files.cpp.

Here is the caller graph for this function:

◆ removeConfigKeys()

void removeConfigKeys ( const char *  key1,
const char *  key2,
char *  fbuf 
)

Removes all lines containing "key1 key2" from the text in fbuf.

Parameters
[in]key1
[in]key2
[out]fbufThe text buffer to process.

Definition at line 1413 of file pps-files.cpp.

Here is the caller graph for this function:

◆ replaceNTPConfig()

int replaceNTPConfig ( const char *  fbuf)

Replaces the NTP config file with the text in fbuf using write before replace after first backing up /etc/ntp.conf if the backup does not already exist.

Parameters
[in]fbufThe replacement text.
Returns
0 on success, else -1 on error.

Definition at line 1369 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ restartNTP()

int restartNTP ( void  )

Restarts NTP with error message handling.

Returns
0 on success, else the system errno on failure.

Definition at line 1350 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveDoubleArray()

int saveDoubleArray ( double  distrib[],
const char *  filename,
int  len,
int  arrayZero 
)

Saves a distribution consisting of an array of doubles.

Parameters
[in]distribThe distribution array.
[in]filenameThe file to save to.
[in]lenThe length of the array.
[in]arrayZeroThe array index of distribution value zero.
Returns
0 on success, else -1 on error.

Definition at line 991 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showStatusEachSecond()

void showStatusEachSecond ( void  )

Reads the state params saved to shared memory by the PPS-Client daemon and prints the param string to the console each second.

Definition at line 1767 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysCommand()

int sysCommand ( const char *  cmd)

Definition at line 89 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TERMhandler()

void TERMhandler ( int  sig)

Responds to the SIGTERM signal by starting the exit sequence in the daemon.

Parameters
[in]sigThe signal from the system.

Definition at line 2088 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeDistribution()

void writeDistribution ( int  distrib[],
int  len,
int  scaleZero,
int  count,
int *  last_epoch,
const char *  distrib_file,
const char *  last_distrib_file 
)

Writes an accumulating statistical distribution to disk and rolls over the accumulating data to a new file every epoch counts and begins a new distribution file. An epoch is 86,400 counts.

Parameters
[in]distribThe array containing the distribution.
[in]lenThe length of the array.
[in]scaleZeroThe array index corresponding to distribution zero.
[in]countThe current number of samples in the distribution.
[out]last_epochThe saved count of the previous epoch.
[in]distrib_fileThe filename of the last completed distribution file.
[in]last_distrib_fileThe filename of the currently forming distribution file.

Definition at line 759 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeErrorDistribFile()

void writeErrorDistribFile ( void  )

Writes a distribution to disk approximately once a minute containing 60 additional time correction samples derived from the PPS interrupt. The distribution is rolled over to a new file every 24 hours.

Definition at line 917 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeFileMsgToLog()

int writeFileMsgToLog ( const char *  filename)

Writes the message saved in the file to pps-client.log.

Parameters
[in]filenameFile containg a message.
Returns
0 on success, else -1 on error;

Definition at line 437 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeFileMsgToLogbuf()

int writeFileMsgToLogbuf ( const char *  filename,
char *  logbuf 
)

Writes the message saved in the file to pps-client.log.

This function is used by threads in pps-sntp.cpp.

Parameters
[in]filenameFile containg a message.
[out]logbufThe log file buffer.
Returns
0 on success, else -1 on error;

Definition at line 393 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeFrequencyVars()

void writeFrequencyVars ( const char *  filename)

Writes the last 24 hours of clock frequency offset and Allan deviation in each 5 minute interval indexed by the timestamp at each interval.

Parameters
[in]filenameThe file to write to.

Definition at line 958 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeIntrptDistribFile()

void writeIntrptDistribFile ( void  )

Writes a multiple distribution to disk containing 60 additional calibration interrupt delays approximately every minute. One is generated for each diffent sysDelay that occurs over the test period.

Collects one day of interrupt delay samples before rolling over a new file.

Definition at line 878 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeJitterDistribFile()

void writeJitterDistribFile ( void  )

Writes a distribution to disk approximately once a minute containing 60 additional jitter samples recorded at the occurrance of the PPS interrupt. The distribution is rolled over to a new file every 24 hours.

Definition at line 903 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeMultipleDistrib()

void writeMultipleDistrib ( int  label[],
int  distrib[][INTRPT_DISTRIB_LEN],
int  len,
int  scaleZero,
int  count,
int *  last_epoch,
const char *  distrib_file,
const char *  last_distrib_file 
)

Writes multiple distributions with a separate distribution in each column of the file after the first for each sysDelay value that occurs.

The first line of the file lists the sysDelay values as column headings. The second line of the file lists the column total samples.

Rolls over the accumulating data to a new file every epoch counts and begins a new distribution file. An epoch is 86,400 counts.

Parameters
[in]labelThe sysDelay values for each column.
[in]distribThe arrays containing the distributions.
[in]lenThe length of the distrib[] arrays.
[in]scaleZeroThe array index corresponding to distribution zero.
[in]countThe current total number of samples in the distributions.
[out]last_epochThe saved count of the previous epoch.
[in]distrib_fileThe filename of the last completed distribution file.
[in]last_distrib_fileThe filename of the currently forming file.

Definition at line 810 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeOffsets()

void writeOffsets ( const char *  filename)

Writes the previously completed list of 10 minutes of recorded time offsets and applied frequency offsets indexed by seq_num.

Parameters
[in]filenameThe file to write to.

Definition at line 931 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeStatusStrings()

int writeStatusStrings ( void  )

Writes status strings accumulated in a message buffer, g.savebuf, from bufferStateParams() and other sources to a tmpfs memory file, displayParams_file, once each second. This file can be displayed in real time by invoking the PPS-Client program with the -v command line flag while the PPS-Client daemon is running.

Returns
0 on success, else -1 on error.

Definition at line 316 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeSysDelay()

void writeSysDelay ( void  )

Write g.sysDelay to a temporary file each second.

The sysDelay value can be read by other programs that are timing external interrupts.

Definition at line 1157 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeSysdelayDistribFile()

void writeSysdelayDistribFile ( void  )

Writes a distribution to disk containing 60 additional sysDelay samples approximately every minute. Collects one day of sysDelay samples before rolling over a new file.

Definition at line 890 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeTimestamp()

void writeTimestamp ( double  timestamp)

Write a timestamp provided as a double to a temporary file each second.

Parameters
[in]timestampThe timestamp value.

Definition at line 1179 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeToLog()

void writeToLog ( char *  logbuf)

Appends logbuf to the log file with a timestamp.

Parameters
[in,out]logbufPointer to the log buffer.

Definition at line 247 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeToLogNoTimestamp()

void writeToLogNoTimestamp ( char *  logbuf)

Appends logbuf to the log file.

Parameters
[in,out]logbufPointer to the log buffer.

Definition at line 215 of file pps-files.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ arrayData

struct saveFileData arrayData[]
Initial value:
= {
{"rawError", g.rawErrorDistrib, "/var/local/pps-raw-error-distrib", ERROR_DISTRIB_LEN, 2, RAW_ERROR_ZERO},
{"intrptError", g.intrptErrorDistrib, "/var/local/pps-intrpt-error-distrib", ERROR_DISTRIB_LEN, 2, RAW_ERROR_ZERO},
{"frequency-vars", NULL, "/var/local/pps-frequency-vars", 0, 3, 0},
{"pps-offsets", NULL, "/var/local/pps-offsets", 0, 4, 0}
}
struct G g
Declares the global variables defined in pps-client.h.
Definition: pps-client.cpp:53
#define RAW_ERROR_ZERO
Index corresponding to rawError == 0 in detectDelayPeak().
Definition: pps-client.h:67
#define ERROR_DISTRIB_LEN
Definition: pps-client.h:95
double rawErrorDistrib[ERROR_DISTRIB_LEN]
The distribution used to detect a delay shift in detectDelayPeak().
Definition: pps-client.h:192

Data associations for PPS-Client command line save data requests with the -s flag.

Definition at line 181 of file pps-files.cpp.

◆ arrayData_file

const char* arrayData_file = "/run/shm/pps-save-data"

Stores a request sent to the PPS-Client daemon.

Definition at line 45 of file pps-files.cpp.

◆ assert_file

const char* assert_file = "/run/shm/pps-assert"

The timestamps of the time corrections each second.

Definition at line 43 of file pps-files.cpp.

◆ config_file

const char* config_file = "/etc/pps-client.conf"

The PPS-Client configuration file.

Definition at line 37 of file pps-files.cpp.

◆ displayParams_file

const char* displayParams_file = "/run/shm/pps-display-params"

Temporary file storing params for the status display.

Definition at line 44 of file pps-files.cpp.

◆ distrib_file

const char* distrib_file = "/var/local/pps-error-distrib-forming"

Stores a forming distribution of offset corrections.

Definition at line 26 of file pps-files.cpp.

◆ g

struct G g

Declares the global variables defined in pps-client.h.

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

◆ intrpt_distrib_file

const char* intrpt_distrib_file = "/var/local/pps-intrpt-distrib-forming"

Stores a forming distribution of offset corrections.

Definition at line 32 of file pps-files.cpp.

◆ jitter_distrib_file

const char* jitter_distrib_file = "/var/local/pps-jitter-distrib-forming"

Stores a forming distribution of offset corrections.

Definition at line 28 of file pps-files.cpp.

◆ last_distrib_file

const char* last_distrib_file = "/var/local/pps-error-distrib"

Stores the completed distribution of offset corrections.

Definition at line 25 of file pps-files.cpp.

◆ last_intrpt_distrib_file

const char* last_intrpt_distrib_file = "/var/local/pps-intrpt-distrib"

Stores the completed distribution of offset corrections.

Definition at line 31 of file pps-files.cpp.

◆ last_jitter_distrib_file

const char* last_jitter_distrib_file = "/var/local/pps-jitter-distrib"

Stores the completed distribution of offset corrections.

Definition at line 27 of file pps-files.cpp.

◆ last_sysDelay_distrib_file

const char* last_sysDelay_distrib_file = "/var/local/pps-sysDelay-distrib"

Stores a distribution of sysDelay.

Definition at line 34 of file pps-files.cpp.

◆ log_file

const char* log_file = "/var/log/pps-client.log"

Stores activity and errors.

Definition at line 29 of file pps-files.cpp.

◆ ntp_config_bac

const char* ntp_config_bac = "/etc/ntp.conf.bac"

Backup of the NTP configuration file.

Definition at line 39 of file pps-files.cpp.

◆ ntp_config_file

const char* ntp_config_file = "/etc/ntp.conf"

The NTP configuration file.

Definition at line 38 of file pps-files.cpp.

◆ ntp_config_part

const char* ntp_config_part = "/etc/ntp.conf.part"

Temporary filename for an NTP config file during copy.

Definition at line 40 of file pps-files.cpp.

◆ num

const char* num = "0123456789."

Definition at line 48 of file pps-files.cpp.

◆ old_log_file

const char* old_log_file = "/var/log/pps-client.old.log"

Stores activity and errors.

Definition at line 30 of file pps-files.cpp.

◆ pidFilename

const char* pidFilename = "/var/run/pps-client.pid"

Stores the PID of PPS-Client.

Definition at line 35 of file pps-files.cpp.

◆ space

const char* space = " "

Definition at line 47 of file pps-files.cpp.

◆ sysDelay_distrib_file

const char* sysDelay_distrib_file = "/var/local/pps-sysDelay-distrib-forming"

Stores a forming distribution of sysDelay values.

Definition at line 33 of file pps-files.cpp.

◆ sysDelay_file

const char* sysDelay_file = "/run/shm/pps-sysDelay"

The current sysDelay value updated each second.

Definition at line 42 of file pps-files.cpp.

◆ valid_config

const char* valid_config[]
Initial value:
= {
"error-distrib",
"alert-pps-lost",
"jitter-distrib",
"calibrate",
"interrupt-distrib",
"sysdelay-distrib",
"exit-lost-pps",
"pps-gpio",
"output-gpio",
"intrpt-gpio",
"sntp",
"serial",
"serialPort"
}

Recognized configuration strings for the PPS-Client configuration file.

Definition at line 69 of file pps-files.cpp.

◆ version

const char* version

Program version 1.4.0 created on 17 Dec 2017.

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