= PPSAPI Interface for Precision Time Signals
include::include-html.ad[]

[cols="10%,90%",frame="none",grid="none",style="verse"]
|==============================
|image:pic/tonea.gif[]|
{millshome}pictures.html[from 'NBS Special Publication 432, 1979'] (out of print)

|==============================

== Related Links

include::includes/misc.adoc[]

'''''

== Introduction

RFC 2783 describes the PPSAPI application programming interface for
external precision time signals, such as the pulse-per-second (PPS)
signal generated by some radio clocks and cesium oscillators. The PPSAPI
provides a generic capability in the ubiquitous Unix kernel which can be
used for a wide variety of measurement applications, including network
time synchronization and related experiments. The hardware to do this
requires only a serial port and a modem control lead, such as the data
carrier detect (DCD) lead, which can be driven by an external source via
a level converter/pulse generator such as described on the
link:pps.html[Pulse-per-second (PPS) Signal Interfacing] page. In some
systems a parallel port can be used for the same purpose.

The PPSAPI interface defined in RFC 2783 is the only PPS interface
supported in NTP Version 4. The PPSAPI is supported in stock FreeBSD
and in Linux.

The special header file +/usr/include/sys/timepps.h+ implements the
PPSAPI using whatever primitives are available in each architecture and
operating system. It obsoletes previous APIs based on the +tty_clock+
and +ppsclock+ line disciplines and streams modules, which are no longer
supported.

The link:driver_pps.html[PPS Clock Discipline] driver
uses the PPSAPI in conjunction with a local radio clock or remote
NTP server as a reference clock. The driver can also use the PPSAPI as
an interface directly to the kernel PPS facility as described on the
link:kern.html[Kernel Model for Precision Timekeeping] page.

== PPSAPI Application Program Interface

The PPSAPI interface provides the following functions:

+time_pps_create+::
  Creates a PPS interface instance and returns a handle to it.
+time_pps_destroy+::
  Destroys a PPS interface and returns the resources used.
+time_pps_setparams+::
  Sets the parameters associated with a PPS interface instance,
  including offsets to be automatically added to captured timestamps.
+time_pps_getparams+::
  Returns the parameters associated with a PPS interface instance.
+time_pps_getcap+::
  Returns the capabilities of the current interface and kernel
  implementation.
+time_pps_fetch+::
  Returns the current timestamps associated with a PPS interface
  instance in either seconds and nanoseconds (Unix +timespec+) or
  seconds and fraction (NTP) format.
+time_pps_kcbind+::
  If kernel PPS processing is supported, this binds the support to the
  associated PPS interface instance.

The entire PPS interface functionality is currently provided by inline
code in the +timepps.h+ header file. While not all implementations
support the full PPSAPI specification, they do support all the functions
required for the PPS driver described next. The FreeBSD, Linux and
Solaris implementations can be used with the stock kernels provided with
those systems; however, the Tru64 and SunOS kernels require additional
functions not provided in the stock kernels. Solaris users are cautioned
that these functions operate improperly in Solaris versions prior to 2.8
with patch Generic_108528-02. Header files for other systems can be
found via the web at
https://www.eecis.udel.edu/~ntp/ntp_spool/software/nanokernel.tar.gz[nanokernel.tar.gz].

'''''

'''''

include::includes/footer.adoc[]
