Project

General

Profile

Starting and using TDUControl » History » Version 15

Thomas Dealtry, 01/30/2015 10:22 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 9 Thomas Dealtry
-s    calls <code>do_time_sync()</code>
49 9 Thomas Dealtry
-d    calls <code>do_delay_calc()</code>
50 9 Thomas Dealtry
-P    calls <code>do_ping()</code>
51 9 Thomas Dealtry
-g    calls <code>get_status()</code>
52 9 Thomas Dealtry
</pre>
53 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_xmlrpcserver.py
54 8 Thomas Dealtry
55 9 Thomas Dealtry
h2. Communication with TDU directly
56 9 Thomas Dealtry
57 9 Thomas Dealtry
<pre>
58 9 Thomas Dealtry
python rc/tdu/testing_scripts/tdu_control_via_client.py -T 192.168.100.201 -p 10001
59 9 Thomas Dealtry
</pre>
60 9 Thomas Dealtry
By default this will <code>do_ping()</code>, and if successful <code>do_time_sync()</code>.
61 9 Thomas Dealtry
A couple of switches allow you to do more:
62 9 Thomas Dealtry
<pre>
63 9 Thomas Dealtry
-d    calls <code>do_delay_calc()</code>
64 9 Thomas Dealtry
-t    calls <code>debug_read_all_registers()</code>
65 9 Thomas Dealtry
</pre>
66 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
67 9 Thomas Dealtry
68 9 Thomas Dealtry
h2. Running an emulator
69 9 Thomas Dealtry
70 9 Thomas Dealtry
If you don't have access to the hardware, you can run on a (very basic) emulator.
71 1 Kurt Biery
72 9 Thomas Dealtry
<pre>
73 9 Thomas Dealtry
python $LBNERCROOT/rc/tdu/testing_scripts/tdu_emulator.py -T localhost -P 50007
74 9 Thomas Dealtry
</pre>
75 9 Thomas Dealtry
76 10 Thomas Dealtry
h1. List of commands
77 1 Kurt Biery
78 8 Thomas Dealtry
All 'get', 'do', and 'read' commands return an error code with a common numbering scheme. 'get' commands also return additional information.
79 6 Thomas Dealtry
80 6 Thomas Dealtry
h2. 'get' commands
81 6 Thomas Dealtry
82 6 Thomas Dealtry
* <code>get_status()</code>
83 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)
84 6 Thomas Dealtry
85 14 Thomas Dealtry
* <code>get_nova_time(init_nova_time=False)</code>
86 14 Thomas Dealtry
Returns [error_code, nova_time]. nova_time is a 64-bit integer.
87 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?)
88 14 Thomas Dealtry
89 6 Thomas Dealtry
h2. 'do' commands
90 6 Thomas Dealtry
91 14 Thomas Dealtry
All 'do' commands should be run on the master
92 14 Thomas Dealtry
93 6 Thomas Dealtry
* <code>do_ping()</code>
94 6 Thomas Dealtry
ping the TDU
95 6 Thomas Dealtry
96 6 Thomas Dealtry
* <code>do_time_sync()</code>
97 6 Thomas Dealtry
Perform a time synchronisation (this calls <code>get_status()</code> internally)
98 6 Thomas Dealtry
99 6 Thomas Dealtry
* <code>do_delay_calc()</code>
100 6 Thomas Dealtry
Perform a propagation delay calculation (this calls <code>get_status()</code> internally)
101 6 Thomas Dealtry
102 6 Thomas Dealtry
* <code>do_send_sync_pulse()</code>
103 6 Thomas Dealtry
Send a sync pulse (this calls <code>get_status()</code> internally)
104 6 Thomas Dealtry
105 6 Thomas Dealtry
* <code>debug_do_write_control_reg(data_to_or)</code>
106 6 Thomas Dealtry
Write the control register to perform a none standard operation (this calls <code>get_status()</code> internally)
107 6 Thomas Dealtry
108 6 Thomas Dealtry
h2. 'read' commands
109 6 Thomas Dealtry
110 6 Thomas Dealtry
* <code>read_tdu_id()</code>
111 6 Thomas Dealtry
Read out the TDU version & ID numbers
112 6 Thomas Dealtry
113 6 Thomas Dealtry
* <code>read_tdu_status()</code>
114 6 Thomas Dealtry
Read out the TDU's current operating conditions (current, voltage, temperature, fan status, FPGA status)
115 6 Thomas Dealtry
116 6 Thomas Dealtry
* <code>read_gps_status()</code>
117 6 Thomas Dealtry
Read out the GPS status (faults, timeouts, sat count, etc. + current UTC time)
118 6 Thomas Dealtry
119 6 Thomas Dealtry
* <code>read_error_registers()</code>
120 6 Thomas Dealtry
Read out the error registers
121 6 Thomas Dealtry
122 6 Thomas Dealtry
* <code>read_control_reg()</code>
123 6 Thomas Dealtry
Read out the control register
124 6 Thomas Dealtry
125 6 Thomas Dealtry
* <code>debug_read_all_registers()</code>
126 6 Thomas Dealtry
Read out all the registers. Also comes with some hints on what the 'default' for normal operating conditions is.
127 6 Thomas Dealtry
128 7 Thomas Dealtry
h2. Other commands
129 6 Thomas Dealtry
130 6 Thomas Dealtry
* <code>close_socket()</code>
131 6 Thomas Dealtry
Safely close the connection to the TDU
132 6 Thomas Dealtry
133 6 Thomas Dealtry
h2. Error codes
134 1 Kurt Biery
135 7 Thomas Dealtry
<pre>
136 7 Thomas Dealtry
100-120    Wrong number of bytes received
137 7 Thomas Dealtry
-200/-201  Invalid register/data on receive
138 7 Thomas Dealtry
+200/+201  Invalid register/data on send
139 1 Kurt Biery
300        Cannot perform a 'do' command (get_status() returns ready_to_do=False after 10 attempts including 2 seconds of sleep)
140 1 Kurt Biery
301        Not ready to sync (TDU status error)
141 7 Thomas Dealtry
302        Not ready to sync (GPS status error)
142 7 Thomas Dealtry
400        Error found in error registers
143 14 Thomas Dealtry
500        Propagation delay calculation failure
144 10 Thomas Dealtry
</pre>
145 6 Thomas Dealtry
146 6 Thomas Dealtry
h1. List of TDU IP addresses
147 1 Kurt Biery
148 1 Kurt Biery
* Master: 192.168.100.201
149 1 Kurt Biery
* Slave: 192.168.100.202
150 14 Thomas Dealtry
* ... (to be expanded)
151 10 Thomas Dealtry
152 10 Thomas Dealtry
The port is ALWAYS 10001 (unless you're communciating with an emulator)
153 14 Thomas Dealtry
154 14 Thomas Dealtry
All 'do' commands should be run on the master.
155 9 Thomas Dealtry
156 6 Thomas Dealtry
h1. Using the NOvA GUI (TDUControl) - OLD & BROKEN
157 6 Thomas Dealtry
158 1 Kurt Biery
To start TDUControl, use the following steps:
159 6 Thomas Dealtry
160 5 Thomas Dealtry
# log into the <code>lbnedaq</code> account on <code>lbne35t-gateway01</code>
161 6 Thomas Dealtry
# <code>source /data/lbnedaq/novadaq/setup/setup_novadaq_nt1.sh</code>
162 6 Thomas Dealtry
# <code>TDUControl -m</code>
163 5 Thomas Dealtry
# enter the IP address of the Master TDU into the GUI (192.168.100.201)
164 1 Kurt Biery
165 6 Thomas Dealtry
Alternatively for steps 3 & 4, you can run <code>TDUControl -m -t 192.168.100.201</code>