Skip to main content

TPM multicast client

Project description

tpm_multicast_client

Versions Code style: black Test codecov

Listens to the TPM multicast stream and unpack the data into a status dictionary. This is a Python-only implementation of Jeff Hagen's tpmdgram.c.

Installation

To install with pip do

pip install sdss-tpm-multicast-client

To install from source do

pip install .

or, for development,

poetry install

More information on developing with Poetry can be found here.

Usage

The library provides a single function, listen_to_multicast, that creates a connection to the TPM broadcast, unpacks the datagram, and passes it to a callback function. A basic example

from pprint import pprint

from tpm_multicast_client import __version__, listen_to_multicast


def pprint_datagram(data: dict):
    pprint(data)

async def main():
    _, protocol = await listen_to_multicast(pprint_datagram)
    await protocol.run_forever()


if __name__ == "__main__":
    main()

The callback, pprint_datagram in this case, can be a function or a coroutine. In the former case it will be called with loop.call_soon(). In the latter the coroutine is scheduled as a task.

CLI

The library provides a simple CLI script tpm-multicast-client that prints the output of the datagram to stdout. It's basically equivalent to the example above.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sdss_tpm_multicast_client-0.3.1.tar.gz (6.0 kB view hashes)

Uploaded Source

Built Distribution

sdss_tpm_multicast_client-0.3.1-py3-none-any.whl (8.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page