Re: PPS lock status from C

Miroslav Lichvar <[email protected]>
Newsgroups gmane.comp.time.chrony.user
Message-ID <ZLfzNPStKmOp868r@localhost>
On Tue, Jul 18, 2023 at 04:34:19PM -0700, Thangalin wrote:
>   adjtimex(&t);
>   printf( "%d\n", t.status & STA_PPSSIGNAL);
> }
> 
> That works for ntpd, not for chronyd.

This works only when ntpd is configured to give up the control of the
clock to the kernel (kernel PPS discipline).

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

You would need to open the chronyd socket and send a request to it
before you get a message containing CMD_Reply.

There is a new library which makes this much easier:
https://gitlab.com/chrony/libchrony

See the example.

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

There is no solution that would work for both chronyd and ntpd. They
use different monitoring protocols. The ntp distribution includes
libntpq.

-- 
Miroslav Lichvar


-- 
To unsubscribe email chrony-users-request-kWFZVVI9zxvPqho9SqqRMmD2FQJk+8+b@public.gmane.org 
with "unsubscribe" in the subject.
For help email chrony-users-request-kWFZVVI9zxvPqho9SqqRMmD2FQJk+8+b@public.gmane.org 
with "help" in the subject.
Trouble?  Email [email protected]
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.