Overview
This is a Pure Python PPS interface following RFC2783. A PPPPS interface, if you would.
This has the unfortunate task of rolling-up some system and implementation
specific knowledge into the Python layers. I could have thrown in the towel and
added dependencies on cython and timepps interfaces on the system, but that
would have required external dependencies and added build complexity.
Prerequisites
Python: 3.5+
OSs:
- Linux
- FreeBSD
Note that Linux support may vary depending on the platform, as the ioctl
request values vary ever so slightly (and annoyingly). This is setup to use
the asm-generic ioctl constants, which should work on ARM and x86_64. Buyer
beware.
Interface
This strives to implement a reasonable subset of RFC2783 with python
abstractions instead of nitty-gritty C structures. Under the hood, there are
nitty-gritty C structures (care of ctypes) to interface with the kernel.
More information can be found at https://datatracker.ietf.org/doc/html/rfc2783.
This library does NOT support optional behavior, such as:
- the
ntp_fp_ttimestamp format kcbind
Installation
From pypi:
pip install pps-tools
From your local checkout:
pip install [--user] .
Usage
Command-line
This installs a pps-tools command with the fetch and params subcommands.
Access to the PPS devices, especially setting parameters may require elevated
privileges.
The fetch command mirrors time_pps_fetch(), printing out the assert or
clear events for the PPS device, depending on its current mode. This includes
the event time and count. The event assert or clear will be printed depending
on the device's current mode.
$ pps-tools fetch /dev/pps0
assert 8078 @ 1627007608.079880476
assert 8079 @ 1627007609.093453169
...
The params command mirrors time_pps_getparams() and time_pps_setparams().
After optionally setting parameters, the updated params are fetched and printed
to stdout. In addition, this prints out the capabilities (time_pps_getcap())
in a verbose fashion.
$ pps-tools params /dev/pps0
API Version : 1
Assert Offset : 0.0
Clear Offset : 0.0
Current Mode : 0x0001
PPS_CAPTUREASSERT : 1
PPS_CAPTURECLEAR : 0
PPS_OFFSETASSERT : 0
PPS_OFFSETCLEAR : 0
PPS_ECHOASSERT : 0
PPS_ECHOCLEAR : 0
PPS_CANWAIT : 0
PPS_CANPOLL : 0
PPS_TSFMT_TSPEC : 0
PPS_TSFMT_NTPFP : 0
Capabilities : 0x1133
PPS_CAPTUREASSERT : 1
PPS_CAPTURECLEAR : 1
PPS_OFFSETASSERT : 1
PPS_OFFSETCLEAR : 1
PPS_ECHOASSERT : 0
PPS_ECHOCLEAR : 0
PPS_CANWAIT : 1
PPS_CANPOLL : 0
PPS_TSFMT_TSPEC : 1
PPS_TSFMT_NTPFP : 0
Python Library
The PPS interface can be used in Python through the PpsFile class. Example:
import pps_tools
with pps_tools.PpsFile("/dev/pps0") as ppsf:
capabilities = ppsf.get_cap()
print(pps_tools.data.cap_to_dict(capabilities))
params = ppsf.get_params()
params['mode'] = pps_tools.data.PPS_CAPTUREASSERT
ppsf.set_params(**params)
edge = ppsf.fetch(timeout=None)
print(edge)
See the PpsFile method documentation for more information.
The library takes care of mapping Python objects to the underlying C structures
for the given platform. It also takes care of calling CREATE and DESTROY
ioctls for the given file, even though it doesn't usually do anything in the
kernel.
The pps_tools.data module contains the C structures and ioctl constants for
the given platform. These can be used if one wishes to interact with the PPS
device directly.
Metadata
Release files for pps-tools 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pps_tools-2.1.0.tar.gz | 10.3 kB | Without provenance | Details for pps_tools-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pps_tools-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for pps_tools-2.1.0-py3-none-any.whl |
Total release size: 20.7 kB
Release files / pps_tools-2.1.0.tar.gz
| Download URL | pps_tools-2.1.0.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67fbe1cd482d69bab17f692c951e332ec6877e0a910006b9550dbf6a5bf43c5a
|
|
BLAKE2b-256 checksum How to use checksums |
fb97bc237c118fd56141ac9d1f119b86702142e5e151d24a03bdfdc99e4436de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.19
|
Release files / pps_tools-2.1.0-py3-none-any.whl
| Download URL | pps_tools-2.1.0-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a7c399d3487b7db822a575b3530ac1ba407dce9ac0adc8cea24be5251dd424c3
|
|
BLAKE2b-256 checksum How to use checksums |
3696927375aea7ff1e3548c21e3dca8973a185aa8be5b82329d9e7b432d6ce09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.19
|
Security for pps-tools 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.