Project

General

Profile

Starting and using TDUControl » History » Version 20

Thomas Dealtry, 03/24/2015 06:21 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 18 Thomas Dealtry
Source the lbnerc code (up to date instructions at [[Running_DAQ_Interface]])
23 1 Kurt Biery
24 1 Kurt Biery
<pre>
25 18 Thomas Dealtry
cd /data/lbnedaq/daqarea
26 18 Thomas Dealtry
source fireup
27 8 Thomas Dealtry
</pre>
28 8 Thomas Dealtry
29 18 Thomas Dealtry
In the following, $LBNERCROOT refers to the root path of your lbnerc install (it's not actually a variable that's set!)
30 1 Kurt Biery
31 18 Thomas Dealtry
Using the xmlrpc server is preferred, since the TDU can only handle a single connection at a time (using the xmlrpc server is a good way to prevent problems if multiple processes attempt to control the TDU at the same time).
32 18 Thomas Dealtry
33 18 Thomas Dealtry
It should also be noted the the _default_ values of host and ports of the TDU and XMLRPC server in the scripts here are what is shown here, therefore, in most circumstances, you can run without providing these options.
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 20 Thomas Dealtry
The result of each command is printed to screen, along with "(SUCCESS)" or "(FAILURE)".
57 20 Thomas Dealtry
58 16 Thomas Dealtry
To kill the xmlrpc server, pass the <code>-k</code> argument to <code>tdu_control_via_xmlrpcserver.py</code>.
59 16 Thomas Dealtry
60 9 Thomas Dealtry
h2. Communication with TDU directly
61 9 Thomas Dealtry
62 9 Thomas Dealtry
<pre>
63 17 Thomas Dealtry
python rc/tdu/testing_scripts/tdu_control_via_client.py -T 192.168.100.201 -P 10001
64 9 Thomas Dealtry
</pre>
65 9 Thomas Dealtry
By default this will <code>do_ping()</code>, and if successful <code>do_time_sync()</code>.
66 9 Thomas Dealtry
A couple of switches allow you to do more:
67 9 Thomas Dealtry
<pre>
68 9 Thomas Dealtry
-d    calls <code>do_delay_calc()</code>
69 9 Thomas Dealtry
-t    calls <code>debug_read_all_registers()</code>
70 9 Thomas Dealtry
</pre>
71 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
72 9 Thomas Dealtry
73 9 Thomas Dealtry
h2. Running an emulator
74 9 Thomas Dealtry
75 9 Thomas Dealtry
If you don't have access to the hardware, you can run on a (very basic) emulator.
76 1 Kurt Biery
77 9 Thomas Dealtry
<pre>
78 9 Thomas Dealtry
python $LBNERCROOT/rc/tdu/testing_scripts/tdu_emulator.py -T localhost -P 50007
79 9 Thomas Dealtry
</pre>
80 9 Thomas Dealtry
81 10 Thomas Dealtry
h1. List of commands
82 1 Kurt Biery
83 19 Thomas Dealtry
All 'get', 'do', and 'read' commands return an error code with a common numbering scheme ("0" means success). 'get' commands also return additional information.
84 6 Thomas Dealtry
85 6 Thomas Dealtry
h2. 'get' commands
86 6 Thomas Dealtry
87 6 Thomas Dealtry
* <code>get_status()</code>
88 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)
89 6 Thomas Dealtry
90 14 Thomas Dealtry
* <code>get_nova_time(init_nova_time=False)</code>
91 14 Thomas Dealtry
Returns [error_code, nova_time]. nova_time is a 64-bit integer.
92 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?)
93 14 Thomas Dealtry
94 6 Thomas Dealtry
h2. 'do' commands
95 6 Thomas Dealtry
96 14 Thomas Dealtry
All 'do' commands should be run on the master
97 14 Thomas Dealtry
98 6 Thomas Dealtry
* <code>do_ping()</code>
99 6 Thomas Dealtry
ping the TDU
100 6 Thomas Dealtry
101 6 Thomas Dealtry
* <code>do_time_sync()</code>
102 6 Thomas Dealtry
Perform a time synchronisation (this calls <code>get_status()</code> internally)
103 6 Thomas Dealtry
104 6 Thomas Dealtry
* <code>do_delay_calc()</code>
105 6 Thomas Dealtry
Perform a propagation delay calculation (this calls <code>get_status()</code> internally)
106 6 Thomas Dealtry
107 6 Thomas Dealtry
* <code>do_send_sync_pulse()</code>
108 6 Thomas Dealtry
Send a sync pulse (this calls <code>get_status()</code> internally)
109 6 Thomas Dealtry
110 6 Thomas Dealtry
* <code>debug_do_write_control_reg(data_to_or)</code>
111 6 Thomas Dealtry
Write the control register to perform a none standard operation (this calls <code>get_status()</code> internally)
112 6 Thomas Dealtry
113 6 Thomas Dealtry
h2. 'read' commands
114 6 Thomas Dealtry
115 6 Thomas Dealtry
* <code>read_tdu_id()</code>
116 6 Thomas Dealtry
Read out the TDU version & ID numbers
117 6 Thomas Dealtry
118 6 Thomas Dealtry
* <code>read_tdu_status()</code>
119 6 Thomas Dealtry
Read out the TDU's current operating conditions (current, voltage, temperature, fan status, FPGA status)
120 6 Thomas Dealtry
121 6 Thomas Dealtry
* <code>read_gps_status()</code>
122 6 Thomas Dealtry
Read out the GPS status (faults, timeouts, sat count, etc. + current UTC time)
123 6 Thomas Dealtry
124 6 Thomas Dealtry
* <code>read_error_registers()</code>
125 6 Thomas Dealtry
Read out the error registers
126 6 Thomas Dealtry
127 6 Thomas Dealtry
* <code>read_control_reg()</code>
128 6 Thomas Dealtry
Read out the control register
129 6 Thomas Dealtry
130 6 Thomas Dealtry
* <code>debug_read_all_registers()</code>
131 6 Thomas Dealtry
Read out all the registers. Also comes with some hints on what the 'default' for normal operating conditions is.
132 6 Thomas Dealtry
133 7 Thomas Dealtry
h2. Other commands
134 6 Thomas Dealtry
135 6 Thomas Dealtry
* <code>close_socket()</code>
136 1 Kurt Biery
Safely close the connection to the TDU
137 1 Kurt Biery
138 16 Thomas Dealtry
* <code>reinit_client(ntries)</code>
139 16 Thomas Dealtry
Calls <code>close_socket()</code>, and then performs <code>ntries</code> attempts to reconnect to the TDU (with 10 second sleeps)
140 16 Thomas Dealtry
141 1 Kurt Biery
h2. Error codes
142 1 Kurt Biery
143 1 Kurt Biery
<pre>
144 19 Thomas Dealtry
0          Success!
145 16 Thomas Dealtry
100-119    Wrong number of bytes received
146 16 Thomas Dealtry
120-139    Zero bytes received - connection to the TDU has probably been lost, try resending command to find out
147 16 Thomas Dealtry
140-159    Connection to TDU was lost, but has been recovered. Resend your command
148 7 Thomas Dealtry
-200/-201  Invalid register/data on receive
149 7 Thomas Dealtry
+200/+201  Invalid register/data on send
150 1 Kurt Biery
300        Cannot perform a 'do' command (get_status() returns ready_to_do=False after 10 attempts including 2 seconds of sleep)
151 1 Kurt Biery
301        Not ready to sync (TDU status error)
152 7 Thomas Dealtry
302        Not ready to sync (GPS status error)
153 7 Thomas Dealtry
400        Error found in error registers
154 14 Thomas Dealtry
500        Propagation delay calculation failure
155 10 Thomas Dealtry
</pre>
156 6 Thomas Dealtry
157 6 Thomas Dealtry
h1. List of TDU IP addresses
158 1 Kurt Biery
159 1 Kurt Biery
* Master: 192.168.100.201
160 1 Kurt Biery
* Slave: 192.168.100.202
161 14 Thomas Dealtry
* ... (to be expanded)
162 10 Thomas Dealtry
163 10 Thomas Dealtry
The port is ALWAYS 10001 (unless you're communciating with an emulator)
164 14 Thomas Dealtry
165 14 Thomas Dealtry
All 'do' commands should be run on the master.
166 9 Thomas Dealtry
167 6 Thomas Dealtry
h1. Using the NOvA GUI (TDUControl) - OLD & BROKEN
168 6 Thomas Dealtry
169 1 Kurt Biery
To start TDUControl, use the following steps:
170 6 Thomas Dealtry
171 5 Thomas Dealtry
# log into the <code>lbnedaq</code> account on <code>lbne35t-gateway01</code>
172 6 Thomas Dealtry
# <code>source /data/lbnedaq/novadaq/setup/setup_novadaq_nt1.sh</code>
173 6 Thomas Dealtry
# <code>TDUControl -m</code>
174 5 Thomas Dealtry
# enter the IP address of the Master TDU into the GUI (192.168.100.201)
175 1 Kurt Biery
176 6 Thomas Dealtry
Alternatively for steps 3 & 4, you can run <code>TDUControl -m -t 192.168.100.201</code>