Project

General

Profile

Starting and using TDUControl » History » Version 17

Thomas Dealtry, 03/09/2015 10:26 AM

1 6 Thomas Dealtry
{{toc}}
2 1 Kurt Biery
3 6 Thomas Dealtry
h1. Getting help
4 6 Thomas Dealtry
5 6 Thomas Dealtry
Email Tom Dealtry - thomas.dealtry@physics.ox.ac.uk
6 6 Thomas Dealtry
7 6 Thomas Dealtry
h1. Overview
8 6 Thomas Dealtry
9 13 Thomas Dealtry
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
10 6 Thomas Dealtry
11 10 Thomas Dealtry
There are a couple of ways to communicate with the TDU:
12 1 Kurt Biery
13 13 Thomas Dealtry
* [[Starting_and_using_TDUControl#Communication via xmlrpc server|Booting up an xmlrpc server & commuicating through this]] (preferred)
14 10 Thomas Dealtry
* [[Starting_and_using_TDUControl#Communication with TDU directly|Communicating with the TDU directly]]
15 1 Kurt Biery
16 10 Thomas Dealtry
[[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]]
17 10 Thomas Dealtry
18 11 Thomas Dealtry
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.
19 10 Thomas Dealtry
20 8 Thomas Dealtry
h1. Communication with the TDU
21 8 Thomas Dealtry
22 8 Thomas Dealtry
The following will get Python 2.7.8, and set the environment (the code lives in lbnerc, located at /data/lbnedaq/tdu/lbnerc/)
23 8 Thomas Dealtry
(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)
24 8 Thomas Dealtry
25 8 Thomas Dealtry
<pre>
26 8 Thomas Dealtry
source /data/lbnedaq/daqarea/lbne-artdaq-base/setupLBNEARTDAQ
27 8 Thomas Dealtry
cd /data/lbnedaq/tdu/
28 8 Thomas Dealtry
source fireup_tdu
29 8 Thomas Dealtry
</pre>
30 1 Kurt Biery
31 1 Kurt Biery
$LBNERCROOT refers to the root path of your lbnerc install (it's not actually a variable that's set!)
32 13 Thomas Dealtry
33 13 Thomas Dealtry
Using the xmlrpc server is preferred, since the TDU can only handle a single connection at a time.
34 9 Thomas Dealtry
35 8 Thomas Dealtry
h2. Communication via xmlrpc server
36 8 Thomas Dealtry
37 9 Thomas Dealtry
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.
38 9 Thomas Dealtry
<pre>
39 9 Thomas Dealtry
tdu -T 192.168.100.201 -P 10001 -H localhost -r 50008
40 9 Thomas Dealtry
</pre>
41 8 Thomas Dealtry
42 9 Thomas Dealtry
Next, you can use call the xmlrpc server to communicate with the TDU.
43 9 Thomas Dealtry
<pre>
44 9 Thomas Dealtry
python rc/tdu/testing_scripts/tdu_control_via_xmlrpcserver.py -T localhost -p 50008
45 9 Thomas Dealtry
</pre>
46 9 Thomas Dealtry
This will print out a list of commands and exit. To actually do something, add one (or more) switches
47 9 Thomas Dealtry
<pre>
48 1 Kurt Biery
-P    calls <code>do_ping()</code>
49 1 Kurt Biery
-g    calls <code>get_status()</code>
50 16 Thomas Dealtry
-s    calls <code>do_time_sync()</code>
51 16 Thomas Dealtry
-d    calls <code>do_delay_calc()</code> followed by <code>do_time_sync()</code>
52 9 Thomas Dealtry
</pre>
53 16 Thomas Dealtry
Note that you can use multiple switches in a single call, and operations are performed in the order listed above.
54 1 Kurt Biery
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
55 1 Kurt Biery
56 16 Thomas Dealtry
To kill the xmlrpc server, pass the <code>-k</code> argument to <code>tdu_control_via_xmlrpcserver.py</code>.
57 16 Thomas Dealtry
58 9 Thomas Dealtry
h2. Communication with TDU directly
59 9 Thomas Dealtry
60 9 Thomas Dealtry
<pre>
61 17 Thomas Dealtry
python rc/tdu/testing_scripts/tdu_control_via_client.py -T 192.168.100.201 -P 10001
62 9 Thomas Dealtry
</pre>
63 9 Thomas Dealtry
By default this will <code>do_ping()</code>, and if successful <code>do_time_sync()</code>.
64 9 Thomas Dealtry
A couple of switches allow you to do more:
65 9 Thomas Dealtry
<pre>
66 9 Thomas Dealtry
-d    calls <code>do_delay_calc()</code>
67 9 Thomas Dealtry
-t    calls <code>debug_read_all_registers()</code>
68 9 Thomas Dealtry
</pre>
69 9 Thomas Dealtry
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
70 9 Thomas Dealtry
71 9 Thomas Dealtry
h2. Running an emulator
72 9 Thomas Dealtry
73 9 Thomas Dealtry
If you don't have access to the hardware, you can run on a (very basic) emulator.
74 1 Kurt Biery
75 9 Thomas Dealtry
<pre>
76 9 Thomas Dealtry
python $LBNERCROOT/rc/tdu/testing_scripts/tdu_emulator.py -T localhost -P 50007
77 9 Thomas Dealtry
</pre>
78 9 Thomas Dealtry
79 10 Thomas Dealtry
h1. List of commands
80 1 Kurt Biery
81 8 Thomas Dealtry
All 'get', 'do', and 'read' commands return an error code with a common numbering scheme. 'get' commands also return additional information.
82 6 Thomas Dealtry
83 6 Thomas Dealtry
h2. 'get' commands
84 6 Thomas Dealtry
85 6 Thomas Dealtry
* <code>get_status()</code>
86 6 Thomas Dealtry
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)
87 6 Thomas Dealtry
88 14 Thomas Dealtry
* <code>get_nova_time(init_nova_time=False)</code>
89 14 Thomas Dealtry
Returns [error_code, nova_time]. nova_time is a 64-bit integer.
90 15 Thomas Dealtry
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?)
91 14 Thomas Dealtry
92 6 Thomas Dealtry
h2. 'do' commands
93 6 Thomas Dealtry
94 14 Thomas Dealtry
All 'do' commands should be run on the master
95 14 Thomas Dealtry
96 6 Thomas Dealtry
* <code>do_ping()</code>
97 6 Thomas Dealtry
ping the TDU
98 6 Thomas Dealtry
99 6 Thomas Dealtry
* <code>do_time_sync()</code>
100 6 Thomas Dealtry
Perform a time synchronisation (this calls <code>get_status()</code> internally)
101 6 Thomas Dealtry
102 6 Thomas Dealtry
* <code>do_delay_calc()</code>
103 6 Thomas Dealtry
Perform a propagation delay calculation (this calls <code>get_status()</code> internally)
104 6 Thomas Dealtry
105 6 Thomas Dealtry
* <code>do_send_sync_pulse()</code>
106 6 Thomas Dealtry
Send a sync pulse (this calls <code>get_status()</code> internally)
107 6 Thomas Dealtry
108 6 Thomas Dealtry
* <code>debug_do_write_control_reg(data_to_or)</code>
109 6 Thomas Dealtry
Write the control register to perform a none standard operation (this calls <code>get_status()</code> internally)
110 6 Thomas Dealtry
111 6 Thomas Dealtry
h2. 'read' commands
112 6 Thomas Dealtry
113 6 Thomas Dealtry
* <code>read_tdu_id()</code>
114 6 Thomas Dealtry
Read out the TDU version & ID numbers
115 6 Thomas Dealtry
116 6 Thomas Dealtry
* <code>read_tdu_status()</code>
117 6 Thomas Dealtry
Read out the TDU's current operating conditions (current, voltage, temperature, fan status, FPGA status)
118 6 Thomas Dealtry
119 6 Thomas Dealtry
* <code>read_gps_status()</code>
120 6 Thomas Dealtry
Read out the GPS status (faults, timeouts, sat count, etc. + current UTC time)
121 6 Thomas Dealtry
122 6 Thomas Dealtry
* <code>read_error_registers()</code>
123 6 Thomas Dealtry
Read out the error registers
124 6 Thomas Dealtry
125 6 Thomas Dealtry
* <code>read_control_reg()</code>
126 6 Thomas Dealtry
Read out the control register
127 6 Thomas Dealtry
128 6 Thomas Dealtry
* <code>debug_read_all_registers()</code>
129 6 Thomas Dealtry
Read out all the registers. Also comes with some hints on what the 'default' for normal operating conditions is.
130 6 Thomas Dealtry
131 7 Thomas Dealtry
h2. Other commands
132 6 Thomas Dealtry
133 6 Thomas Dealtry
* <code>close_socket()</code>
134 1 Kurt Biery
Safely close the connection to the TDU
135 1 Kurt Biery
136 16 Thomas Dealtry
* <code>reinit_client(ntries)</code>
137 16 Thomas Dealtry
Calls <code>close_socket()</code>, and then performs <code>ntries</code> attempts to reconnect to the TDU (with 10 second sleeps)
138 16 Thomas Dealtry
139 1 Kurt Biery
h2. Error codes
140 1 Kurt Biery
141 1 Kurt Biery
<pre>
142 16 Thomas Dealtry
100-119    Wrong number of bytes received
143 16 Thomas Dealtry
120-139    Zero bytes received - connection to the TDU has probably been lost, try resending command to find out
144 16 Thomas Dealtry
140-159    Connection to TDU was lost, but has been recovered. Resend your command
145 7 Thomas Dealtry
-200/-201  Invalid register/data on receive
146 7 Thomas Dealtry
+200/+201  Invalid register/data on send
147 1 Kurt Biery
300        Cannot perform a 'do' command (get_status() returns ready_to_do=False after 10 attempts including 2 seconds of sleep)
148 1 Kurt Biery
301        Not ready to sync (TDU status error)
149 7 Thomas Dealtry
302        Not ready to sync (GPS status error)
150 7 Thomas Dealtry
400        Error found in error registers
151 14 Thomas Dealtry
500        Propagation delay calculation failure
152 10 Thomas Dealtry
</pre>
153 6 Thomas Dealtry
154 6 Thomas Dealtry
h1. List of TDU IP addresses
155 1 Kurt Biery
156 1 Kurt Biery
* Master: 192.168.100.201
157 1 Kurt Biery
* Slave: 192.168.100.202
158 14 Thomas Dealtry
* ... (to be expanded)
159 10 Thomas Dealtry
160 10 Thomas Dealtry
The port is ALWAYS 10001 (unless you're communciating with an emulator)
161 14 Thomas Dealtry
162 14 Thomas Dealtry
All 'do' commands should be run on the master.
163 9 Thomas Dealtry
164 6 Thomas Dealtry
h1. Using the NOvA GUI (TDUControl) - OLD & BROKEN
165 6 Thomas Dealtry
166 1 Kurt Biery
To start TDUControl, use the following steps:
167 6 Thomas Dealtry
168 5 Thomas Dealtry
# log into the <code>lbnedaq</code> account on <code>lbne35t-gateway01</code>
169 6 Thomas Dealtry
# <code>source /data/lbnedaq/novadaq/setup/setup_novadaq_nt1.sh</code>
170 6 Thomas Dealtry
# <code>TDUControl -m</code>
171 5 Thomas Dealtry
# enter the IP address of the Master TDU into the GUI (192.168.100.201)
172 1 Kurt Biery
173 6 Thomas Dealtry
Alternatively for steps 3 & 4, you can run <code>TDUControl -m -t 192.168.100.201</code>