PPS-Client
2.0.0
Client for synchronizing the system clock to a GPS PPS source
|
This file contains functions and structures for saving and loading files intended for PPS-Client status monitoring and analysis. More...
#include "../client/pps-client.h"
Go to the source code of this file.
Functions | |
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, const char *location) |
void | errorReadingMsgTo (char *logbuf, const char *filename) |
void | writeToLogNoTimestamp (char *logbuf) |
void | writeToLog (char *logbuf, const char *location) |
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, const char *location) |
int | saveLastState (void) |
int | loadLastState (void) |
int | writeFileMsgToLogbuf (const char *filename, char *logbuf) |
int | writeFileMsgToLog (const char *filename) |
pid_t | getChildPID (void) |
bool | ppsIsRunning (void) |
int | createPIDfile (void) |
int | readConfigFile (const char *fconfig) |
void | writeDistribution (int distrib[], int len, int scaleZero, int count, int *last_epoch, const char *distrib_file, const char *last_distrib_file) |
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 | getSharedConfigs (void) |
int | getConfigs (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) |
void | removeConfigKeys (const char *key1, const char *key2, char *fbuf) |
char * | getLinuxVersion (void) |
int | getRPiCPU (void) |
int | assignProcessorAffinity (void) |
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) |
void | recordFrequencyVars (void) |
void | recordOffsets (int timeCorrection) |
int | find_source (const char *path, pps_handle_t *handle, int *avail_mode) |
int | readPPSTimestamp (pps_handle_t *handle, int *avail_mode, int *tm) |
int | getRootHome (void) |
Variables | |
struct G | g |
Declares the global variables defined in pps-client.h. More... | |
const char * | config_file = "/XXXX/pps-client.conf" |
The PPS-Client configuration file. More... | |
const char * | last_distrib_file = "/pps-error-distrib" |
Stores the completed distribution of offset corrections. More... | |
const char * | distrib_file = "/pps-error-distrib-forming" |
Stores a forming distribution of offset corrections. More... | |
const char * | last_jitter_distrib_file = "/pps-jitter-distrib" |
Stores the completed distribution of offset corrections. More... | |
const char * | jitter_distrib_file = "/pps-jitter-distrib-forming" |
Stores a forming distribution of offset corrections. More... | |
const char * | log_file = "/pps-client.log" |
Stores activity and errors. More... | |
const char * | old_log_file = "/pps-client.old.log" |
Stores activity and errors. More... | |
const char * | pidFilename = "/pps-client.pid" |
Stores the PID of PPS-Client. More... | |
const char * | assert_file = "/pps-assert" |
The timestamps of the time corrections each second. More... | |
const char * | displayParams_file = "/pps-display-params" |
Temporary file storing params for the status display. More... | |
const char * | arrayData_file = "/pps-save-data" |
Stores a request sent to the PPS-Client daemon. More... | |
const char * | pps_msg_file = "/pps-msg" |
const char * | linuxVersion_file = "/linuxVersion" |
const char * | gmtTime_file = "/gmtTime" |
const char * | nistTime_file = "/nist_out" |
const char * | integral_state_file = "/.pps-last-state" |
const char * | home_file = "/Home" |
const char * | cpuinfo_file = "/cpuinfo" |
const char * | space = " " |
const char * | num = "0123456789." |
const char * | version |
Program v2.0.0 updated on 9 Jul 2020. More... | |
bool | writeJitterDistrib = false |
bool | writeErrorDistrib = false |
struct ppsFiles | f |
PPS-Client internal files. More... | |
const char * | valid_config [] |
struct saveFileData | arrayData [] |
This file contains functions and structures for saving and loading files intended for PPS-Client status monitoring and analysis.
Definition in file pps-files.cpp.
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.
[in] | argc | System command line arg |
[in] | argv | System command line arg |
Definition at line 2238 of file pps-files.cpp.
References f, getSharedConfigs(), INThandler(), missingArg(), parseSaveDataRequest(), ppsIsRunning(), printAcceptedArgs(), showStatusEachSecond(), and version.
Referenced by main().
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.
[in] | token | The token string preceding the number to be aligned. |
[in,out] | buf | The buffer containing the token. |
[in] | len | The initial length of the buffer. |
Definition at line 1613 of file pps-files.cpp.
References g, and writeToLog().
Referenced by bufferStateParams().
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.
[in] | refToken | The reference token which is followed by a number having a variable length. |
[in] | offset | The number of characters in the adjusted buffer from the end of refToken to the start of token. |
[in] | token | The token to be aligned. |
[out] | buf | The buffer containing the tokens. |
[in] | len | the initial length of the buffer. |
Definition at line 1654 of file pps-files.cpp.
References g, and writeToLog().
Referenced by bufferStateParams().
int assignProcessorAffinity | ( | void | ) |
Segregate PPS-Client to a separate core from the other processes running on the processor.
Not all will be movable. Error messages are generated for the ones that can't be moved but those messages are suppressed.
Definition at line 1877 of file pps-files.cpp.
References g, G::nCores, sysCommand(), and G::useCore.
Referenced by initialize().
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.
Definition at line 1693 of file pps-files.cpp.
References alignNumbersAfter(), alignTokens(), G::avgCorrection, bufferStatusMsg(), G::clampAbsolute, G::freqOffset, g, G::hardLimit, G::interruptLossCount, and G::seq_num.
Referenced by waitForPPS().
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().
[in] | msg | Pointer to the message to be concatenated. |
Definition at line 407 of file pps-files.cpp.
References g, G::isVerbose, and MSGBUF_SZ.
Referenced by bufferStateParams(), main(), readPPS_SetTime(), writeToLog(), and writeToLogNoTimestamp().
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.
[in] | timeCorrection | The time correction value to be accumulated to a distribution. |
Definition at line 2294 of file pps-files.cpp.
References ERROR_DISTRIB_LEN, and g.
Referenced by removeNoise().
void buildJitterDistrib | ( | int | rawError | ) |
Constructs a distribution of jitter that can be saved to disk for analysis.
[in] | rawError | The raw error jitter value to save to the distribution. |
Definition at line 2316 of file pps-files.cpp.
References g, and JITTER_DISTRIB_LEN.
Referenced by removeNoise().
void couldNotOpenMsgTo | ( | char * | logbuf, |
const char * | filename, | ||
const char * | location | ||
) |
Constructs an error message.
Definition at line 306 of file pps-files.cpp.
Referenced by open_logerr(), writeFileMsgToLogbuf(), writeToLog(), and writeToLogNoTimestamp().
int createPIDfile | ( | void | ) |
Creates a PID file for the PPS-Client daemon.
Definition at line 875 of file pps-files.cpp.
References f, g, open_logerr(), and writeToLog().
Referenced by main().
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.
[in] | requestStr | The request string. |
[in] | filename | The shared memory file to write to. |
Definition at line 2123 of file pps-files.cpp.
References f, g, open_logerr(), and writeToLog().
Referenced by parseSaveDataRequest().
void errorReadingMsgTo | ( | char * | logbuf, |
const char * | filename | ||
) |
Constructs an error message.
Definition at line 319 of file pps-files.cpp.
Referenced by read_logerr(), and writeFileMsgToLogbuf().
int find_source | ( | const char * | path, |
pps_handle_t * | handle, | ||
int * | avail_mode | ||
) |
Establishes a connection to the system PPS driver.
[in] | path | The driver path. Usually /dev/pps0. |
[out] | handle | A handle to the driver. |
[out] | avail_mode | Info needed when accessing the driver. |
Definition at line 2433 of file pps-files.cpp.
References g, and writeToLog().
Referenced by main().
pid_t getChildPID | ( | void | ) |
Reads the PID of the child process when the parent process needs to kill it.
Definition at line 804 of file pps-files.cpp.
References f, g, open_logerr(), read_logerr(), and STRBUF_SZ.
int getConfigs | ( | void | ) |
Processes the files and configuration settings specified by the PPS-Client config file for the pps-client daemon.
Definition at line 1356 of file pps-files.cpp.
References arrayData_file, assert_file, config_file, cpuinfo_file, displayParams_file, distrib_file, G::doNISTsettime, G::doSerialsettime, ERROR_DISTRIB, ERROR_DISTRIB_LEN, EXIT_LOST_PPS, f, g, getString(), gmtTime_file, home_file, isDisabled(), isEnabled(), JITTER_DISTRIB, jitter_distrib_file, JITTER_DISTRIB_LEN, last_distrib_file, last_jitter_distrib_file, linuxVersion_file, log_file, LOGDIR, G::nCores, NIST, nistTime_file, old_log_file, pidFilename, pps_msg_file, PPSDELAY, PPSDEVICE, PPSPHASE, G::ppsPhase, PROCDIR, processWriteRequest(), readConfigFile(), RUNDIR, SEGREGATE, SERIAL, SERIAL_PORT, SHMDIR, TSTDIR, G::useCore, writeErrorDistrib, writeErrorDistribFile(), writeJitterDistrib, writeJitterDistribFile(), and G::zeroOffset.
Referenced by initialize(), and waitForPPS().
char* getLinuxVersion | ( | void | ) |
Returns the Linux kernel version string corresponding to 'uname -r'.
Definition at line 1801 of file pps-files.cpp.
References f, g, G::linuxVersion, sysCommand(), and writeToLog().
int getRootHome | ( | void | ) |
Definition at line 2545 of file pps-files.cpp.
References f, g, integral_state_file, sysCommand(), and writeToLog().
Referenced by main().
int getRPiCPU | ( | void | ) |
Returns the principle version number of this CPU if it is a Raspberry Pi.
Definition at line 1834 of file pps-files.cpp.
References CONFIG_FILE_SZ, f, g, open_logerr(), and writeToLog().
Referenced by initialize().
int getSeqNum | ( | const char * | pbuf | ) |
Extracts the sequence number G.seq_num from a char string and returns the value.
[in] | pbuf | The string to search. |
Definition at line 1984 of file pps-files.cpp.
Referenced by showStatusEachSecond().
int getSharedConfigs | ( | void | ) |
Gets the daemon internal file names and state params for accessDaemon(). Necessary because daemons can not directly share contents of variables.
Definition at line 1273 of file pps-files.cpp.
References arrayData_file, assert_file, config_file, displayParams_file, distrib_file, G::doNISTsettime, G::doSerialsettime, f, g, getString(), home_file, isDisabled(), isEnabled(), last_distrib_file, last_jitter_distrib_file, log_file, LOGDIR, NIST, old_log_file, pidFilename, pps_msg_file, readConfigFile(), RUNDIR, SERIAL, SERIAL_PORT, SHMDIR, and TSTDIR.
Referenced by accessDaemon().
char* getString | ( | int | key | ) |
Retrieves the string from the config file assigned to the valid_config string with value key.
[in] | key | The config key corresponding to a string in the valid_config[] array above. |
Definition at line 212 of file pps-files.cpp.
References g.
Referenced by getConfigs(), and getSharedConfigs().
bool hasString | ( | int | key, |
const char * | string | ||
) |
Tests configuration strings from 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)].
[in] | key | The config key corresponding to a string in the valid_config[] array above. |
[in] | string | The string that must be matched by the string that follows the config string name from the valid_config[] array. |
Definition at line 253 of file pps-files.cpp.
References g.
Referenced by isDisabled(), and isEnabled().
void HUPhandler | ( | int | sig | ) |
Catches the SIGHUP signal, causing it to be ignored.
[in] | sig | The signal from the system. |
Definition at line 2350 of file pps-files.cpp.
Referenced by waitForPPS().
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.
[in] | sig | The signal returned by the system. |
Definition at line 2091 of file pps-files.cpp.
References g.
Referenced by accessDaemon().
bool isDisabled | ( | int | key | ) |
Tests configuration strings from pps-client.conf for the "disable" keyword.
[in] | key | The config key corresponding to a string in the valid_config[] array above. |
Definition at line 289 of file pps-files.cpp.
References hasString().
Referenced by getConfigs(), and getSharedConfigs().
bool isEnabled | ( | int | key | ) |
Tests configuration strings from pps-client.conf for the "enable" keyword.
[in] | key | The config key corresponding to a string in the valid_config[] array above. |
Definition at line 275 of file pps-files.cpp.
References hasString().
Referenced by getConfigs(), and getSharedConfigs().
int loadLastState | ( | void | ) |
Loads the last state corresponding to the makeTimeCorrection() integrators on startup to allow rapid restart.
Definition at line 610 of file pps-files.cpp.
References G::activeCount, adjtimex(), ADJTIMEX_SCALE, G::avgIntegral, G::correctionAccum, G::correctionFifo, G::correctionFifo_idx, G::correctionFifoCount, f, G::freqOffset, g, G::hardLimit, G::integral, integral_state_file, G::integralCount, G::integralGain, G::integralTimeCorrection, G::isControlling, NUM_INTEGRALS, OFFSETFIFO_LEN, read_logerr(), SECS_PER_MINUTE, G::seq_num, G::slewIsLow, and G::t3.
Referenced by waitForPPS().
bool missingArg | ( | int | argc, |
char * | argv[], | ||
int | i | ||
) |
Checks for and reports on missing arguments in a command line request.
[in] | argc | System command line arg |
[in] | argv | System command line arg |
[in] | i | The arg index. |
Definition at line 2106 of file pps-files.cpp.
Referenced by accessDaemon(), and parseSaveDataRequest().
int open_logerr | ( | const char * | filename, |
int | flags, | ||
const char * | location | ||
) |
Opens a file with error logging and sets standard file permissions for O_CREAT.
[in] | filename | The file to open. |
[in] | flags | The file open flags. |
[in] | location | The name of the calling function. |
Definition at line 486 of file pps-files.cpp.
References couldNotOpenMsgTo(), g, and writeToLog().
Referenced by createPIDfile(), daemonSaveArray(), getChildPID(), getRPiCPU(), saveDoubleArray(), saveLastState(), writeDistribution(), writeFrequencyVars(), writeOffsets(), writeStatusStrings(), and writeTimestamp().
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.
[in] | argc | System command line arg |
[in] | argv | System command line arg |
[in] | requestStr | The request string. |
Definition at line 2172 of file pps-files.cpp.
References arrayData, daemonSaveArray(), g, missingArg(), printAcceptedArgs(), and STRBUF_SZ.
Referenced by accessDaemon().
bool ppsIsRunning | ( | void | ) |
Uses a system call to pidof to see if PPS-Client is running.
Definition at line 831 of file pps-files.cpp.
References f, g, sysCommand(), and writeToLog().
Referenced by accessDaemon().
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 2153 of file pps-files.cpp.
References arrayData.
Referenced by accessDaemon(), and parseSaveDataRequest().
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.
Definition at line 1219 of file pps-files.cpp.
References arrayData, f, g, saveDoubleArray(), STRBUF_SZ, writeFrequencyVars(), writeOffsets(), and writeToLog().
Referenced by getConfigs().
int read_logerr | ( | int | fd, |
char * | buf, | ||
int | sz, | ||
const char * | filename | ||
) |
Reads a file with error logging.
[in] | fd | The file descriptor. |
[out] | buf | The buffer to hold the file data. |
[in] | sz | The number of bytes to read. |
[in] | filename | The filename of the file being read. |
Definition at line 466 of file pps-files.cpp.
References errorReadingMsgTo(), g, and writeToLog().
Referenced by getChildPID(), and loadLastState().
int readConfigFile | ( | const char * | fconfig | ) |
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.
[in] | fconfig | Root filename of pps-client.conf. |
Definition at line 922 of file pps-files.cpp.
Referenced by getConfigs(), and getSharedConfigs().
int readPPSTimestamp | ( | pps_handle_t * | handle, |
int * | avail_mode, | ||
int * | tm | ||
) |
Gets the PPS rising edge time from the Linux PPS driver.
[in] | handle | The handle to the system PPS driver. |
[in] | avail_mode | Info for the driver. |
[out] | tm | The timestamp obtained from the driver. |
Definition at line 2505 of file pps-files.cpp.
Referenced by readPPS_SetTime().
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 2366 of file pps-files.cpp.
References FIVE_MINUTES, FREQDIFF_INTRVL, G::freqOffset, g, and NUM_5_MIN_INTERVALS.
Referenced by getIntegral().
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.
[in] | timeCorrection | The time correction value to be recorded. |
Definition at line 2412 of file pps-files.cpp.
References G::freqOffset, g, SECS_PER_10_MIN, and G::seq_num.
Referenced by makeTimeCorrection().
void removeConfigKeys | ( | const char * | key1, |
const char * | key2, | ||
char * | fbuf | ||
) |
Removes all lines containing "key1 key2" from the text in fbuf.
[in] | key1 | |
[in] | key2 | |
[out] | fbuf | The text buffer to process. |
Definition at line 1755 of file pps-files.cpp.
int saveDoubleArray | ( | double | distrib[], |
const char * | filename, | ||
int | len, | ||
int | arrayZero | ||
) |
Saves a distribution consisting of an array of doubles.
[in] | distrib | The distribution array. |
[in] | filename | The file to save to. |
[in] | len | The length of the array. |
[in] | arrayZero | The array index of distribution value zero. |
Definition at line 1177 of file pps-files.cpp.
References g, MAX_LINE_LEN, open_logerr(), and writeToLog().
Referenced by processWriteRequest().
int saveLastState | ( | void | ) |
Saves the state corresponding to the makeTimeCorrection() integrators on exit to allow rapid restart. These are saved to /root/.pps-last-state on the RPi or whatever the root home directory is on other processors.
Definition at line 509 of file pps-files.cpp.
References G::activeCount, G::avgIntegral, G::correctionAccum, G::correctionFifo, G::correctionFifo_idx, G::correctionFifoCount, f, G::freqOffset, g, G::hardLimit, G::integral, integral_state_file, G::integralCount, G::integralTimeCorrection, G::isControlling, NUM_INTEGRALS, OFFSETFIFO_LEN, open_logerr(), G::seq_num, G::slewIsLow, and writeToLog().
Referenced by waitForPPS().
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 2004 of file pps-files.cpp.
References G::doNISTsettime, G::doSerialsettime, f, g, getSeqNum(), MSGBUF_SZ, and setSyncDelay().
Referenced by accessDaemon().
int sysCommand | ( | const char * | cmd | ) |
system() function with error handling.
Definition at line 193 of file pps-files.cpp.
References g, and writeToLog().
Referenced by assignProcessorAffinity(), doTimeFixups(), getLinuxVersion(), getNISTTime(), getRootHome(), main(), ppsIsRunning(), and waitForPPS().
void TERMhandler | ( | int | sig | ) |
Responds to the SIGTERM signal by starting the exit sequence in the daemon.
[in] | sig | The signal from the system. |
Definition at line 2337 of file pps-files.cpp.
References g, and writeToLog().
Referenced by waitForPPS().
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.
[in] | distrib | The array containing the distribution. |
[in] | len | The length of the array. |
[in] | scaleZero | The array index corresponding to distribution zero. |
[in] | count | The current number of samples in the distribution. |
[out] | last_epoch | The saved count of the previous epoch. |
[in] | distrib_file | The filename of the last completed distribution file. |
[in] | last_distrib_file | The filename of the currently forming distribution file. |
Definition at line 1055 of file pps-files.cpp.
References distrib_file, g, last_distrib_file, open_logerr(), SECS_PER_DAY, and writeToLog().
Referenced by writeErrorDistribFile(), and writeJitterDistribFile().
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 1104 of file pps-files.cpp.
References ERROR_DISTRIB_LEN, g, SECS_PER_MINUTE, G::seq_num, SETTLE_TIME, and writeDistribution().
Referenced by getConfigs().
int writeFileMsgToLog | ( | const char * | filename | ) |
Writes the message saved in the file to pps-client.log.
[in] | filename | File containg a message. |
Definition at line 794 of file pps-files.cpp.
References g, and 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.
[in] | filename | File containg a message. |
[out] | logbuf | The log file buffer. |
Definition at line 750 of file pps-files.cpp.
References couldNotOpenMsgTo(), errorReadingMsgTo(), and LOGBUF_SZ.
Referenced by getNISTTime(), and writeFileMsgToLog().
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.
[in] | filename | The file to write to. |
Definition at line 1145 of file pps-files.cpp.
References g, NUM_5_MIN_INTERVALS, open_logerr(), and writeToLog().
Referenced by processWriteRequest().
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 1090 of file pps-files.cpp.
References g, JITTER_DISTRIB_LEN, SECS_PER_MINUTE, G::seq_num, SETTLE_TIME, and writeDistribution().
Referenced by getConfigs().
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.
[in] | filename | The file to write to. |
Definition at line 1118 of file pps-files.cpp.
References g, open_logerr(), SECS_PER_10_MIN, and writeToLog().
Referenced by processWriteRequest().
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.
Definition at line 435 of file pps-files.cpp.
References f, g, open_logerr(), and writeToLog().
Referenced by waitForPPS().
void writeTimestamp | ( | double | timestamp | ) |
Write a timestamp provided as a double to a temporary file each second.
[in] | timestamp | The timestamp value. |
Definition at line 1581 of file pps-files.cpp.
References f, g, open_logerr(), G::seq_num, STRBUF_SZ, and writeToLog().
Referenced by savePPStime().
void writeToLog | ( | char * | logbuf, |
const char * | location | ||
) |
Appends logbuf to the log file with a timestamp.
[in,out] | logbuf | Pointer to the log buffer. |
Definition at line 364 of file pps-files.cpp.
References bufferStatusMsg(), couldNotOpenMsgTo(), f, g, and STRBUF_SZ.
Referenced by alignNumbersAfter(), alignTokens(), createPIDfile(), daemonSaveArray(), detectExteralSystemClockChange(), detectMissedPPS(), find_source(), getLinuxVersion(), getRootHome(), getRPiCPU(), main(), open_logerr(), ppsIsRunning(), processWriteRequest(), read_logerr(), readPPS_SetTime(), saveDoubleArray(), saveGPSTime(), saveLastState(), saveTimestamps(), setClockFractionalSecond(), setClockToGPStime(), setClocktoNISTtime(), setSyncDelay(), sysCommand(), TERMhandler(), waitForPPS(), writeDistribution(), writeFrequencyVars(), writeOffsets(), writeStatusStrings(), and writeTimestamp().
void writeToLogNoTimestamp | ( | char * | logbuf | ) |
Appends logbuf to the log file.
[in,out] | logbuf | Pointer to the log buffer. |
Definition at line 332 of file pps-files.cpp.
References bufferStatusMsg(), couldNotOpenMsgTo(), and f.
Referenced by updateLog().
struct saveFileData arrayData[] |
Data associations for PPS-Client command line save data requests with the -s flag.
Definition at line 289 of file pps-files.cpp.
Referenced by parseSaveDataRequest(), printAcceptedArgs(), and processWriteRequest().
const char* arrayData_file = "/pps-save-data" |
Stores a request sent to the PPS-Client daemon.
Definition at line 37 of file pps-files.cpp.
Referenced by getConfigs(), and getSharedConfigs().
const char* assert_file = "/pps-assert" |
The timestamps of the time corrections each second.
Definition at line 35 of file pps-files.cpp.
Referenced by getConfigs(), and getSharedConfigs().
const char* config_file = "/XXXX/pps-client.conf" |
The PPS-Client configuration file.
Definition at line 27 of file pps-files.cpp.
Referenced by getConfigs(), and getSharedConfigs().
const char* cpuinfo_file = "/cpuinfo" |
Definition at line 44 of file pps-files.cpp.
Referenced by getConfigs().
const char* displayParams_file = "/pps-display-params" |
Temporary file storing params for the status display.
Definition at line 36 of file pps-files.cpp.
Referenced by getConfigs(), and getSharedConfigs().
const char* distrib_file = "/pps-error-distrib-forming" |
Stores a forming distribution of offset corrections.
Definition at line 29 of file pps-files.cpp.
Referenced by getConfigs(), getSharedConfigs(), and writeDistribution().
struct ppsFiles f |
PPS-Client internal files.
PPS-Client internal files.
Definition at line 58 of file pps-files.cpp.
Referenced by accessDaemon(), createPIDfile(), daemonSaveArray(), getChildPID(), getConfigs(), getLinuxVersion(), getRootHome(), getRPiCPU(), getSharedConfigs(), loadLastState(), main(), ppsIsRunning(), processWriteRequest(), saveLastState(), showStatusEachSecond(), writeStatusStrings(), writeTimestamp(), writeToLog(), and writeToLogNoTimestamp().
struct G g |
Declares the global variables defined in pps-client.h.
Definition at line 53 of file pps-client.cpp.
Referenced by alignNumbersAfter(), alignTokens(), assignProcessorAffinity(), bufferStateParams(), bufferStatusMsg(), buildErrorDistrib(), buildJitterDistrib(), createPIDfile(), daemonSaveArray(), find_source(), getChildPID(), getConfigs(), getLinuxVersion(), getRootHome(), getRPiCPU(), getSharedConfigs(), getString(), hasString(), INThandler(), loadLastState(), open_logerr(), parseSaveDataRequest(), ppsIsRunning(), processWriteRequest(), read_logerr(), recordFrequencyVars(), recordOffsets(), saveDoubleArray(), saveLastState(), showStatusEachSecond(), sysCommand(), TERMhandler(), writeDistribution(), writeErrorDistribFile(), writeFileMsgToLog(), writeFrequencyVars(), writeJitterDistribFile(), writeOffsets(), writeStatusStrings(), writeTimestamp(), and writeToLog().
const char* gmtTime_file = "/gmtTime" |
Definition at line 40 of file pps-files.cpp.
Referenced by getConfigs().
const char* home_file = "/Home" |
Definition at line 43 of file pps-files.cpp.
Referenced by getConfigs(), and getSharedConfigs().
const char* integral_state_file = "/.pps-last-state" |
Definition at line 42 of file pps-files.cpp.
Referenced by getRootHome(), loadLastState(), and saveLastState().
const char* jitter_distrib_file = "/pps-jitter-distrib-forming" |
Stores a forming distribution of offset corrections.
Definition at line 31 of file pps-files.cpp.
Referenced by getConfigs().
const char* last_distrib_file = "/pps-error-distrib" |
Stores the completed distribution of offset corrections.
Definition at line 28 of file pps-files.cpp.
Referenced by getConfigs(), getSharedConfigs(), and writeDistribution().
const char* last_jitter_distrib_file = "/pps-jitter-distrib" |
Stores the completed distribution of offset corrections.
Definition at line 30 of file pps-files.cpp.
Referenced by getConfigs(), and getSharedConfigs().
const char* linuxVersion_file = "/linuxVersion" |
Definition at line 39 of file pps-files.cpp.
Referenced by getConfigs().
const char* log_file = "/pps-client.log" |
Stores activity and errors.
Definition at line 32 of file pps-files.cpp.
Referenced by getConfigs(), and getSharedConfigs().
const char* nistTime_file = "/nist_out" |
Definition at line 41 of file pps-files.cpp.
Referenced by getConfigs(), and getNISTTime().
const char* num = "0123456789." |
Definition at line 47 of file pps-files.cpp.
Referenced by getNISTTime(), and getSeqNum().
const char* old_log_file = "/pps-client.old.log" |
Stores activity and errors.
Definition at line 33 of file pps-files.cpp.
Referenced by getConfigs(), and getSharedConfigs().
const char* pidFilename = "/pps-client.pid" |
Stores the PID of PPS-Client.
Definition at line 34 of file pps-files.cpp.
Referenced by getConfigs(), and getSharedConfigs().
const char* pps_msg_file = "/pps-msg" |
Definition at line 38 of file pps-files.cpp.
Referenced by getConfigs(), and getSharedConfigs().
const char* space = " " |
Definition at line 46 of file pps-files.cpp.
Referenced by getSeqNum().
const char* valid_config[] |
Recognized configuration strings for the PPS-Client configuration file. These strings mirror the configuration file keys #defines in pps-client one-to-one and are identical to the strings in the config file. Usually the #define is the the same word in upper case but not always
Definition at line 74 of file pps-files.cpp.
const char* version |
Program v2.0.0 updated on 9 Jul 2020.
System call
Definition at line 53 of file pps-client.cpp.
Referenced by accessDaemon(), and waitForPPS().
bool writeErrorDistrib = false |
Definition at line 58 of file pps-files.cpp.
Referenced by getConfigs(), and removeNoise().
bool writeJitterDistrib = false |
Definition at line 57 of file pps-files.cpp.
Referenced by getConfigs(), and removeNoise().