Name | pps-tools JSON |
Version |
2.0.0
JSON |
| download |
home_page | |
Summary | Pure Python implementation of RFC2783 PPS tools. |
upload_time | 2023-06-24 21:55:30 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.5 |
license | |
keywords |
pps
pps-tools
ppstools
rfc2783
pulse
per
second
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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: 2.7+, 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_t` timestamp format
* `kcbind`
# Installation
From pypi:
```
pip install pps-tools
```
From your local checkout:
```
pip install [--user] .
```
or
```
python setup.py 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 : 0x1111 - PPS_CAPTUREASSERT, PPS_OFFSETASSERT, PPS_CANWAIT, PPS_TSFMT_TSPEC
Capabilities : 0x4369
PPS_CAPTUREASSERT : 1
PPS_CAPTURECLEAR : 0
PPS_OFFSETASSERT : 1
PPS_OFFSETCLEAR : 0
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.
Raw data
{
"_id": null,
"home_page": "",
"name": "pps-tools",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.5",
"maintainer_email": "",
"keywords": "pps,pps-tools,ppstools,RFC2783,pulse,per,second",
"author": "",
"author_email": "\"Stefan R. Filipek\" <srfilipek@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/a3/26/e6e9bae0b2f6d7c43dd1226e631f38f7bfbc0b94f48dfeff023027cc071a/pps-tools-2.0.0.tar.gz",
"platform": null,
"description": "# Overview\nThis is a Pure Python PPS interface following RFC2783. A PPPPS interface,\nif you would.\n\nThis has the unfortunate task of rolling-up some system and implementation\nspecific knowledge into the Python layers. I could have thrown in the towel and\nadded dependencies on `cython` and `timepps` interfaces on the system, but that\nwould have required external dependencies and added build complexity.\n\n# Prerequisites\nPython: 2.7+, 3.5+\n\nOSs:\n* Linux\n* FreeBSD\n\nNote that Linux support may vary depending on the platform, as the `ioctl`\nrequest values vary ever so slightly (and annoyingly). This is setup to use\nthe asm-generic `ioctl` constants, which should work on ARM and x86\\_64. Buyer\nbeware.\n\n# Interface\nThis strives to implement a reasonable subset of RFC2783 with python\nabstractions instead of nitty-gritty C structures. Under the hood, there _are_\nnitty-gritty C structures (care of `ctypes`) to interface with the kernel.\n\nMore information can be found at https://datatracker.ietf.org/doc/html/rfc2783.\n\nThis library does NOT support optional behavior, such as:\n* the `ntp_fp_t` timestamp format\n* `kcbind`\n\n# Installation\nFrom pypi:\n```\npip install pps-tools\n```\n\nFrom your local checkout:\n```\npip install [--user] .\n```\n\nor\n\n```\npython setup.py install [--user]\n```\n\n# Usage\n\n## Command-line\nThis installs a `pps-tools` command with the `fetch` and `params` subcommands.\nAccess to the PPS devices, especially setting parameters may require elevated\nprivileges.\n\nThe `fetch` command mirrors `time_pps_fetch()`, printing out the assert or\nclear events for the PPS device, depending on its current mode. This includes\nthe event time and count. The event assert or clear will be printed depending\non the device's current mode.\n\n```\n$ pps-tools fetch /dev/pps0\nassert 8078 @ 1627007608.079880476\nassert 8079 @ 1627007609.093453169\n...\n```\n\nThe `params` command mirrors `time_pps_getparams()` and `time_pps_setparams()`.\nAfter optionally setting parameters, the updated params are fetched and printed\nto stdout. In addition, this prints out the capabilities (`time_pps_getcap()`)\nin a verbose fashion.\n\n```\n$ pps-tools params /dev/pps0\nAPI Version : 1\nAssert Offset : 0.0\nClear Offset : 0.0\nCurrent Mode : 0x1111 - PPS_CAPTUREASSERT, PPS_OFFSETASSERT, PPS_CANWAIT, PPS_TSFMT_TSPEC\nCapabilities : 0x4369\n PPS_CAPTUREASSERT : 1\n PPS_CAPTURECLEAR : 0\n PPS_OFFSETASSERT : 1\n PPS_OFFSETCLEAR : 0\n PPS_ECHOASSERT : 0\n PPS_ECHOCLEAR : 0\n PPS_CANWAIT : 1\n PPS_CANPOLL : 0\n PPS_TSFMT_TSPEC : 1\n PPS_TSFMT_NTPFP : 0\n```\n\n## Python Library\nThe PPS interface can be used in Python through the `PpsFile` class. Example:\n```\nimport pps_tools\n\nwith pps_tools.PpsFile(\"/dev/pps0\") as ppsf:\n capabilities = ppsf.get_cap()\n print(pps_tools.data.cap_to_dict(capabilities))\n\n params = ppsf.get_params()\n params['mode'] = pps_tools.data.PPS_CAPTUREASSERT\n ppsf.set_params(**params)\n\n edge = ppsf.fetch(timeout=None)\n print(edge)\n```\n\nSee the `PpsFile` method documentation for more information.\n\nThe library takes care of mapping Python objects to the underlying C structures\nfor the given platform. It also takes care of calling `CREATE` and `DESTROY`\n`ioctls` for the given file, even though it doesn't usually do anything in the\nkernel.\n\nThe `pps_tools.data` module contains the C structures and `ioctl` constants for\nthe given platform. These can be used if one wishes to interact with the PPS\ndevice directly.\n",
"bugtrack_url": null,
"license": "",
"summary": "Pure Python implementation of RFC2783 PPS tools.",
"version": "2.0.0",
"project_urls": {
"Bug Tracker": "https://gitlab.com/srfilipek/pps-tools/-/issues",
"Homepage": "https://gitlab.com/srfilipek/pps-tools"
},
"split_keywords": [
"pps",
"pps-tools",
"ppstools",
"rfc2783",
"pulse",
"per",
"second"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "28bdcd1f1cccf7b0008ec33785464cb61078406e2779d00af4233389a50fc8ea",
"md5": "455c05226479d01b878d7f7787a1dc13",
"sha256": "850505635e5df91a07028939fa669a3659201970ff8d85d9b40ac489a72bab9c"
},
"downloads": -1,
"filename": "pps_tools-2.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "455c05226479d01b878d7f7787a1dc13",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.5",
"size": 10445,
"upload_time": "2023-06-24T21:55:29",
"upload_time_iso_8601": "2023-06-24T21:55:29.288702Z",
"url": "https://files.pythonhosted.org/packages/28/bd/cd1f1cccf7b0008ec33785464cb61078406e2779d00af4233389a50fc8ea/pps_tools-2.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a326e6e9bae0b2f6d7c43dd1226e631f38f7bfbc0b94f48dfeff023027cc071a",
"md5": "a69787c4a72596d2b6a3a8a763aa326e",
"sha256": "ab619cac5115726e4a93d8e3af673a37e587d6ac100963b35104f78fafb42ac1"
},
"downloads": -1,
"filename": "pps-tools-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "a69787c4a72596d2b6a3a8a763aa326e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5",
"size": 10287,
"upload_time": "2023-06-24T21:55:30",
"upload_time_iso_8601": "2023-06-24T21:55:30.698838Z",
"url": "https://files.pythonhosted.org/packages/a3/26/e6e9bae0b2f6d7c43dd1226e631f38f7bfbc0b94f48dfeff023027cc071a/pps-tools-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-24 21:55:30",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "srfilipek",
"gitlab_project": "pps-tools",
"lcname": "pps-tools"
}