[chrony-users] PPS lock status from C

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-users Archives ]


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.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/