PPS lock status from C

Thangalin <[email protected]>
Newsgroups gmane.comp.time.chrony.user
Message-ID <CAANrE7oH1Q7jxTwFMS+rV0qMDUHKu_K9nRt=Si=xzShenmn3pw@mail.gmail.com>
Hi all,

My understanding is that we cannot verify the PPS signal lock status using
the adjtimex() function:

int main( int c, char **v ) {
  struct timex t = {0};
  adjtimex(&t);
  printf( "%d\n", t.status & STA_PPSSIGNAL);
}

That works for ntpd, not for chronyd.

Mirsoslav recommended looking at the chrony sources (e.g., client.c,
candm.h). That was helpful. It looks like we'd need to do the following:

* Declare a structure of type CMD_Reply.
* Open the PPS device (e.g., /dev/pps1).
* Read the device data into the CMD_Reply structure.
* Check CMD_Reply.data.source_data.state to RPY_SD_ST_SELECTED.

Is there a simpler way to retrieve the lock status without using the
CMD_Reply structure? That is, something more like:

* Open PPS device
* Read device data into byte buffer (e.g., 4096 bytes)
* Check nth byte == RPY_SD_ST_SELECTED

Ideally, some direction to look at that'd work for both ntpd and chronyd
would be much appreciated. If that's simply not possible, then tips on
creating a simpler solution would also be helpful.

Thank you.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.