[LinuxPPS] How to use PPS to adjust system clock time ?

Rodolfo Giometti giometti at enneenne.com
Sat Feb 16 08:47:32 CET 2019


On 16/02/2019 08:28, Ran Shalit wrote:
> Hello,
> 
> In Linux PPS documentation it is said:
> 
> PPS means "pulse per second" and a PPS source is just a device which
> provides a high precision signal each second so that an application
> can use it to adjust system clock time.
> 
> But I haven't find out how to do this adjusting of system clock timer
> (hwclock).

Hardware realtime clocks are not related to PPS, it's useful to adjust the 
system clock only.

> The requirement of pps in my system: the 1pps comes from GPIO and should be used 
> for timetag of video captured frames from camers.  I rather not using ntp, and 
> instead find a simpler way to achieve it, so that there is no overhead of ntp.
> 
> 1. Is that possible to adjust system timer from PPS (without ntp) ? Is there an 
> example showing how to do it ?

It's possible for sure but I have no idea about where to find a do-it-yourself 
example.

> 2. Is it that the time_pps_kcbind API is responsible to adjust system clock
> with PPS ? Is there an example showing how to do it ?
> 
> I also don't fully understand the pps time interface,as can be read from
> userspace using time_pps_fetch command (see ppstest.c example)
> 
> 3. How is it that pps already have nsec resolution if it is a clock
> which is only "pulse per second" ? Does it mean that the
> time_pps_fetch already gives time which is synchronized with system
> timer ?

You know that pulses arrive every 1 second precisely so if you attach to these 
pulses a timestamp with nsec resolution you can compute how much your system 
clock runs wrong.

Ciao,

Rodolfo

-- 
GNU/Linux Solutions                  e-mail: giometti at enneenne.com
Linux Device Driver                          giometti at linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti



More information about the discussions mailing list