Skip to main content

PyTrbNet

This is a Python package wrapping libtrbnet.so from trbnettools. It allows accessing trbnet registers from Python.

The package comes with two additional features:

  • XmlDb support. Allows to query registers by their name as specified in the corresponding xml file.
  • PCASpy-based EPICS IOC providing TrbNet register status information to the EPICS detector control system.

Installation

This package can be installed from the Python Package Index via:

pip install trbnet

Configuration / Setup

As this Python package depends on the shared library libtrbnet.so for the communication with TrbNet, its location needs to be provided. This can be done by setting the environment variable LIBTRBNET.

libtrbnet.so in turn requires the environment variables DAQOPSERVER (if talking to TrbNet via a trbnetd daemon) or the IP of a TRB Board: TRB3_SERVER (if talking to TrbNet directly).

A fourth environment variable XMLDB comes into play, if the xmldb capabilities of this Python package are to be used. It should point to the location of the xml-db for your system.

Those environment variables can also be set from within Python with their lowercase variants libtrbnet, daqopserver, and trb3_server upon instantiating the TrbNet() class.

Here's an example using environment variables in the shell:

# Setting the relevant environment variables
export LIBTRBNET=/local/gitrepos/trbnettools/trbnetd/libtrbnet.so
export DAQOPSERVER=jspc55.x-matter.uni-frankfurt.de:1
export XMLDB=/local/gitrepos/daqtools/xml-db/database

# example call to get the value in the compile time
# register for all reachable TRBs:
trbcmd.py xmlget 0xffff TrbNet CompileTime

# With the environment variables set, you could also
# run Python and instantiate TrbNet(). It would
# pick up the settings from the exported variables.

or by setting the variables from within Python:

import os
from trbnet import TrbNet

lib = '/local/gitrepos/trbnettools/trbnetd/libtrbnet.so'
host = 'trbnetd_host:8888'
t = TrbNet(libtrbnet=lib, daqopserver=host)
# 0x40 is the register address of CompileTime
t.register_read(0xffff, 0x40)

Usage with Python

To read the content of the register address 0x0 for all connected TrbNet boards (broadcast address 0xffff), do:

import os
from trbnet import TrbNet

t = TrbNet()

response = t.register_read(0xffff, 0x0)
for endpoint in response:
    print("endpoint 0x{:08X} responded with: 0x{:08X}".format(endpoint, response[endpoint]))

The TrbNet() class has the following methods:

  • register_read(trb_address, reg_address)
  • register_write(trb_address, reg_address, value)
  • register_read_mem(trb_address, reg_address, option, size)
  • read_uid(trb_address)
  • Furthermore, multiple methods starting with trb_ (e.g. trb_set_address(uid, endpoint, trb_address)) can be called as they are inherited from the parent class _TrbNet.

Usage of the Terminal Utility trbcmd.py

The package comes with a simple command line utility called trbcmd.py. It is a Python counterpart for the trbcmd utility provided by trbnettools.

What it can do:

read register values

trbcmd.py r 0xffff 0x0

read memory (subsequent register addresses)

Read three registers starting at 0x8005 from all boards:

trbcmd.py rm 0xffff 0x8005 0x3 0x0

xml-db queries

Ask all TrbNet nodes (broadcast 0xffff) for the register value of CompileTime as set in TrbNet.xml:

trbcmd.py xmlget 0xffff TrbNet       CompileTime

Resources

Metadata

Release files for trbnet 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for trbnet 1.0.6
File Interpreter ABI Platform
trbnet-1.0.6-py2.py3-none-any.whl Python 2, Python 3 none any Details

Release files / trbnet-1.0.6-py2.py3-none-any.whl

Download URL trbnet-1.0.6-py2.py3-none-any.whl
Size 18.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a38ac862917d60970aafecbc294607912368d53e9366018470e45c4f1d16c779
BLAKE2b-256 checksum
How to use checksums
6f08354d3cd201c48905b76e59438a1ec7d01f6b88f0d99dfb152f7084cfa938
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Security for trbnet 1.0.6

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page