Project

General

Profile

Starting and using TDUControl » History » Version 16

Version 15 (Thomas Dealtry, 01/30/2015 10:22 AM) → Version 16/21 (Thomas Dealtry, 02/11/2015 07:27 AM)

{{toc}}

h1. Getting help

Email Tom Dealtry - thomas.dealtry@physics.ox.ac.uk

h1. Overview

The following are instructions on how to communicate with the NOvA timing distrubution unit (TDU). The TDU distributes timing information throughout the system, handles synchronisation between boards, and includes automatic propagation delay calculation & compensation. For a full list of functions, check the "TDU FPGA Firmware Guide":https://cdcvs.fnal.gov/redmine/attachments/download/23033/TDU%20FPGA%20Firmware%20Guide.pdf

There are a couple of ways to communicate with the TDU:

* [[Starting_and_using_TDUControl#Communication via xmlrpc server|Booting up an xmlrpc server & commuicating through this]] (preferred)
* [[Starting_and_using_TDUControl#Communication with TDU directly|Communicating with the TDU directly]]

[[Starting_and_using_TDUControl#List of TDU IP addresses|Hardware connection information]]. If you don't have access to the hardware, you can run a basic [[Starting_and_using_TDUControl#Running an emulator|emulator]]

A [[Starting_and_using_TDUControl#List of commands|list of commands]] will show you what you can (currently) do, along with a [[Starting_and_using_TDUControl#Error codes|list of error codes]] for you to understand the response.

h1. Communication with the TDU

The following will get Python 2.7.8, and set the environment (the code lives in lbnerc, located at /data/lbnedaq/tdu/lbnerc/)
(Note when the feature/tdu branch is merged into the develop branch, the normal fireup instructions at https://cdcvs.fnal.gov/redmine/projects/lbne-daq/wiki/Running_DAQ_Interface will work)

<pre>
source /data/lbnedaq/daqarea/lbne-artdaq-base/setupLBNEARTDAQ
cd /data/lbnedaq/tdu/
source fireup_tdu
</pre>

$LBNERCROOT refers to the root path of your lbnerc install (it's not actually a variable that's set!)

Using the xmlrpc server is preferred, since the TDU can only handle a single connection at a time.

h2. Communication via xmlrpc server

The first step is to initialise the xmlrpc server (if it hasn't been already). The options -T and -P refer to the TDU host & port respectively (the master in this example). The optiosn -H and -r refer to the host & port the xmlrpc server is being created on.
<pre>
tdu -T 192.168.100.201 -P 10001 -H localhost -r 50008
</pre>

Next, you can use call the xmlrpc server to communicate with the TDU.
<pre>
python rc/tdu/testing_scripts/tdu_control_via_xmlrpcserver.py -T localhost -p 50008
</pre>
This will print out a list of commands and exit. To actually do something, add one (or more) switches
<pre>
-P -s calls <code>do_ping()</code> <code>do_time_sync()</code>
-g -d calls <code>get_status()</code> <code>do_delay_calc()</code>
-s -P calls <code>do_time_sync()</code> <code>do_ping()</code>
-d -g calls <code>do_delay_calc()</code> followed by <code>do_time_sync()</code> <code>get_status()</code>
</pre>
Note that you can use multiple switches in a single call, and operations are performed in the order listed above.
If you want to do something else, then you can either add in a new option, or write a new script based on tdu_control_via_xmlrpcserver.py

To kill the xmlrpc server, pass the <code>-k</code> argument to <code>tdu_control_via_xmlrpcserver.py</code>.

h2. Communication with TDU directly

<pre>
python rc/tdu/testing_scripts/tdu_control_via_client.py -T 192.168.100.201 -p 10001
</pre>
By default this will <code>do_ping()</code>, and if successful <code>do_time_sync()</code>.
A couple of switches allow you to do more:
<pre>
-d calls <code>do_delay_calc()</code>
-t calls <code>debug_read_all_registers()</code>
</pre>
If you want to do something else, then you can either add in a new option, or write a new script based on tdu_control_via_client.py

h2. Running an emulator

If you don't have access to the hardware, you can run on a (very basic) emulator.

<pre>
python $LBNERCROOT/rc/tdu/testing_scripts/tdu_emulator.py -T localhost -P 50007
</pre>

h1. List of commands

All 'get', 'do', and 'read' commands return an error code with a common numbering scheme. 'get' commands also return additional information.

h2. 'get' commands

* <code>get_status()</code>
Returns [error_code, ready_to_do]. When ready_to_do is True, the control register can be modified (i.e. a 'do' command can be performed)

* <code>get_nova_time(init_nova_time=False)</code>
Returns [error_code, nova_time]. nova_time is a 64-bit integer.
Note: <code>do_time_sync()</code> must have been called since the last power cycle (TOCHECK: or immediately prior to this operation?), or you need to pass a value init_nova_time=True to force an update without the time sync (TOCHECK: does this update the correct register?)

h2. 'do' commands

All 'do' commands should be run on the master

* <code>do_ping()</code>
ping the TDU

* <code>do_time_sync()</code>
Perform a time synchronisation (this calls <code>get_status()</code> internally)

* <code>do_delay_calc()</code>
Perform a propagation delay calculation (this calls <code>get_status()</code> internally)

* <code>do_send_sync_pulse()</code>
Send a sync pulse (this calls <code>get_status()</code> internally)

* <code>debug_do_write_control_reg(data_to_or)</code>
Write the control register to perform a none standard operation (this calls <code>get_status()</code> internally)

h2. 'read' commands

* <code>read_tdu_id()</code>
Read out the TDU version & ID numbers

* <code>read_tdu_status()</code>
Read out the TDU's current operating conditions (current, voltage, temperature, fan status, FPGA status)

* <code>read_gps_status()</code>
Read out the GPS status (faults, timeouts, sat count, etc. + current UTC time)

* <code>read_error_registers()</code>
Read out the error registers

* <code>read_control_reg()</code>
Read out the control register

* <code>debug_read_all_registers()</code>
Read out all the registers. Also comes with some hints on what the 'default' for normal operating conditions is.

h2. Other commands

* <code>close_socket()</code>
Safely close the connection to the TDU

* <code>reinit_client(ntries)</code>
Calls <code>close_socket()</code>, and then performs <code>ntries</code> attempts to reconnect to the TDU (with 10 second sleeps)

h2. Error codes

<pre>
100-119 100-120 Wrong number of bytes received
120-139 Zero bytes received - connection to the TDU has probably been lost, try resending command to find out
140-159 Connection to TDU was lost, but has been recovered. Resend your command

-200/-201 Invalid register/data on receive
+200/+201 Invalid register/data on send
300 Cannot perform a 'do' command (get_status() returns ready_to_do=False after 10 attempts including 2 seconds of sleep)
301 Not ready to sync (TDU status error)
302 Not ready to sync (GPS status error)
400 Error found in error registers
500 Propagation delay calculation failure
</pre>

h1. List of TDU IP addresses

* Master: 192.168.100.201
* Slave: 192.168.100.202
* ... (to be expanded)

The port is ALWAYS 10001 (unless you're communciating with an emulator)

All 'do' commands should be run on the master.

h1. Using the NOvA GUI (TDUControl) - OLD & BROKEN

To start TDUControl, use the following steps:

# log into the <code>lbnedaq</code> account on <code>lbne35t-gateway01</code>
# <code>source /data/lbnedaq/novadaq/setup/setup_novadaq_nt1.sh</code>
# <code>TDUControl -m</code>
# enter the IP address of the Master TDU into the GUI (192.168.100.201)

Alternatively for steps 3 & 4, you can run <code>TDUControl -m -t 192.168.100.201</code>