Package: trbnet
PyTrbNetThis 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.InstallationThis package can be installed from the Python Package
Index via:pip install trbnetConfiguration / SetupAs 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 variableLIBTRBNET.libtrbnet.so in turn requires the environment variablesDAQOPSERVER(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 variableXMLDBcomes 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 variantslibtrbnet,daqopserver, andtrb3_serverupon
instantiating the TrbNet() class.Here's an example using environment variables in the shell:# Setting the relevant environment variablesexportLIBTRBNET=/local/gitrepos/trbnettools/trbnetd/libtrbnet.soexportDAQOPSERVER=jspc55.x-matter.uni-frankfurt.de:1exportXMLDB=/local/gitrepos/daqtools/xml-db/database# example call to get the value in the compile time# register for all reachable TRBs:trbcmd.pyxmlget0xffffTrbNetCompileTime# 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:importosfromtrbnetimportTrbNetlib='/local/gitrepos/trbnettools/trbnetd/libtrbnet.so'host='trbnetd_host:8888't=TrbNet(libtrbnet=lib,daqopserver=host)# 0x40 is the register address of CompileTimet.register_read(0xffff,0x40)Usage with PythonTo read the content of the register address 0x0 for all
connected TrbNet boards (broadcast address 0xffff), do:importosfromtrbnetimportTrbNett=TrbNet()response=t.register_read(0xffff,0x0)forendpointinresponse: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 withtrb_(e.g.trb_set_address(uid, endpoint, trb_address))
can be called as they are inherited fromthe parent class_TrbNet.Usage of the Terminal Utility trbcmd.pyThe package comes with a simple command line utility calledtrbcmd.py.
It is a Python counterpart for the trbcmd utility provided
by trbnettools.What it can do:read register valuestrbcmd.py r 0xffff 0x0read memory (subsequent register addresses)Read three registers starting at 0x8005 from all boards:trbcmd.py rm 0xffff 0x8005 0x3 0x0xml-db queriesAsk all TrbNet nodes (broadcast 0xffff) for the register value of CompileTime as set in TrbNet.xml:trbcmd.py xmlget 0xffff TrbNet       CompileTimeResourcesThe TRB WebsiteTrbNet Manual