DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
timing.cli.debug Namespace Reference

Functions

 debug (obj, device)
 
 inspect (obj, nodes)
 
 ipy (ctx)
 
 uuid (obj)
 
 sfpexpander (obj)
 
 sfp_status (obj)
 
 fanout_sfpscan (obj)
 
 readSFPStatus (aEEProm, aDiag, aLabel)
 

Function Documentation

◆ debug()

timing.cli.debug.debug ( obj,
device )
Timing master commands.

DEVICE: uhal device identifier

Definition at line 28 of file debug.py.

28def debug(obj, device):
29 '''
30 Timing master commands.
31
32 DEVICE: uhal device identifier
33 '''
34 lDevice = obj.mConnectionManager.getDevice(str(device))
35 if obj.mTimeout:
36 lDevice.setTimeoutPeriod(obj.mTimeout)
37
38 echo('Created device ' + click.style(lDevice.id(), fg='blue'))
39
40 lBoardInfo = toolbox.readSubNodes(lDevice.getNode('io.config'), False)
41 lDevice.dispatch()
42
43 # print({ k:v.value() for k,v in lBoardInfo.items()})
44 # raise SystemExit(0)
45
46 echo("Design '{}' on board '{}' on carrier '{}'".format(
47 style(kDesignNameMap[lBoardInfo['design_type'].value()], fg='blue'),
48 style(kBoardNameMap[lBoardInfo['board_type'].value()], fg='blue'),
49 style(kCarrierNameMap[lBoardInfo['carrier_type'].value()], fg='blue')
50 ))
51
52 obj.mDevice = lDevice
53 obj.mBoardType = lBoardInfo['board_type'].value()
54 obj.mCarrierType = lBoardInfo['carrier_type'].value()
55 obj.mDesignType = lBoardInfo['design_type'].value()
56# ------------------------------------------------------------------------------
57
58
59# ------------------------------------------------------------------------------
60@debug.command('inspect')
61@click.argument('nodes')
62@click.pass_obj

◆ fanout_sfpscan()

timing.cli.debug.fanout_sfpscan ( obj)

Definition at line 205 of file debug.py.

205def fanout_sfpscan(obj):
206
207 lDevice = obj.mDevice
208 lBoardType = obj.mBoardType
209
210 if lBoardType != kBoardPC059:
211 print('Wrong board', lBoardType, 'sorry mate')
212 return
213
214
215 lDevice.getNode('io.csr.ctrl.rst_i2cmux').write(0x1)
216 lDevice.dispatch()
217 lDevice.getNode('io.csr.ctrl.rst_i2cmux').write(0x0)
218 lDevice.dispatch()
219 time.sleep(1)
220
221 lSFPNodeName = 'io.i2c'
222 lI2CBusNode = lDevice.getNode(lSFPNodeName)
223 lSwitchSlave = lI2CBusNode.get_slave('SFP_Switch')
224 print(lSwitchSlave.ping())
225
226 # print(lSwitchSlave.read_i2cPrimitive(1))
227 # time.sleep(0.1)
228
229 lSwitchSlave.write_i2cPrimitive([3])
230 print(lSwitchSlave.read_i2cPrimitive(1))
231 print(lSwitchSlave.read_i2cPrimitive(1))
232 print(lSwitchSlave.read_i2cPrimitive(1))
233
234# ------------------------------------------------------------------------------
235@debug.command('sfp-status', short_help="Debug.")
236@click.pass_obj

◆ inspect()

timing.cli.debug.inspect ( obj,
nodes )

Definition at line 63 of file debug.py.

63def inspect(obj, nodes):
64 lDevice = obj.mDevice
65
66 lNodeIds = lDevice.getNodes(nodes.encode('ascii','replace'))
67 lNodeVals = {n:lDevice.getNode(n).read() for n in lNodeIds}
68
69 lDevice.dispatch()
70
71 toolbox.printRegTable(lNodeVals, False)
72# ------------------------------------------------------------------------------
73
74
75# ------------------------------------------------------------------------------
76@debug.command()
77@click.pass_context

◆ ipy()

timing.cli.debug.ipy ( ctx)
Start an interactive IPython session.

The board HwInterface is accessible as 'lDevice'

Definition at line 78 of file debug.py.

78def ipy(ctx):
79 '''
80 Start an interactive IPython session.
81
82 The board HwInterface is accessible as 'lDevice'
83 '''
84 lDevice = ctx.obj.mDevice
85
86 from IPython import embed
87 embed()
88# ------------------------------------------------------------------------------
89
90
91# ------------------------------------------------------------------------------
92@debug.command('uid', short_help="Unique ID reader.")
93@click.pass_obj

◆ readSFPStatus()

timing.cli.debug.readSFPStatus ( aEEProm,
aDiag,
aLabel )

Definition at line 290 of file debug.py.

290def readSFPStatus(aEEProm, aDiag, aLabel):
291
292 def asciidecode( v ):
293 return (''.join([chr(c) for c in v])).rstrip()
294
295 def tempdecode( v ):
296 lSign = -1 if ((v[0]>>7) & 0x1) else 1
297 x = lSign*((v[0] & 0x7f) + v[1]/float(0xff))
298 return '{:.3f} C'.format(x)
299
300 def vccdecode( v ):
301 return '{:.4f} V'.format(((v[0] << 8) + v[1])/float(10000))
302
303 def biascurdecode( v ):
304 return '{:.3f} mA'.format(((v[0] << 8) + v[1])*2e-3)
305
306 def powerdecode( v ):
307 return '{:.3f} mW'.format(((v[0] << 8) + v[1])*1e-3)
308
309
310 echo()
311 lVenInfoEnc = collections.OrderedDict()
312 lVenInfoEnc['Name'] = asciidecode(aEEProm.read_i2cArray(20,16))
313 lVenInfoEnc['OUI'] = '{}.{}.{}'.format(*(aEEProm.read_i2cArray(37,3)))
314 lVenInfoEnc['Part Number'] = asciidecode(aEEProm.read_i2cArray(40,16))
315 lVenInfoEnc['Revision'] = asciidecode(aEEProm.read_i2cArray(56,4))
316 lVenInfoEnc['Serial Number'] = asciidecode(aEEProm.read_i2cArray(68,16))
317 lVenInfoEnc['Day'] = asciidecode(aEEProm.read_i2cArray(88,2))
318 lVenInfoEnc['Month'] = asciidecode(aEEProm.read_i2cArray(86,2))
319 lVenInfoEnc['Year'] = asciidecode(aEEProm.read_i2cArray(84,2))
320
321 secho("{} Vendor info".format(aLabel), fg='cyan')
322 # for k,v in lVenInfoEnc.items():
323 # v = ''.join([chr(c) for c in v])
324 # echo(' - '+k+': '+style(v, fg='cyan'))
325 echo(toolbox.formatDictTable(lVenInfoEnc, aHdr=False, aSort=False))
326 echo()
327 lLaserWl = aEEProm.read_i2cArray(60,2)
328 lLaserWl = (lLaserWl[0] << 8) + lLaserWl[1]
329 echo('Laser Wavelength: '+style(str(lLaserWl)+'nm', fg='cyan'))
330
331 lRegs = collections.OrderedDict()
332
333 lRegs['Identifier'] = aEEProm.read_i2c(0)
334 lRegs['Ext Identifier'] = aEEProm.read_i2c(1)
335 lRegs['Connector'] = aEEProm.read_i2c(2)
336
337 # Transciever Compatinility
338 lTransComp = aEEProm.read_i2cArray(3, 8)
339
340 lRegs['Encoding'] = aEEProm.read_i2c(11)
341 lRegs['BR, Nominal'] = aEEProm.read_i2c(12)
342 lRegs['Rate ID'] = aEEProm.read_i2c(13)
343
344 toolbox.printRegTable(lRegs, aHeader=False, sort=False)
345
346 echo()
347 secho("{} Diagnostic info".format(aLabel), fg='cyan')
348
349 lReadings = collections.OrderedDict()
350
351 lReadings['Temp'] = tempdecode(aDiag.read_i2cArray(96, 2))
352 lReadings['Vcc'] = vccdecode(aDiag.read_i2cArray(98, 2))
353 lReadings['TX bias'] = biascurdecode(aDiag.read_i2cArray(100, 2))
354 lReadings['TX power'] = powerdecode(aDiag.read_i2cArray(102, 2))
355 lReadings['RX power'] = powerdecode(aDiag.read_i2cArray(104, 2))
356 lMiscStatus = aDiag.read_i2c(110)
357 lReadings['TX disable'] = (lMiscStatus >> 7) & 0x1
358
359 # for k,v in lReadings.items():
360 # print (k, v)
361
362 echo(toolbox.formatDictTable(lReadings, aHdr=False, aSort=False))
363# ------------------------------------------------------------------------------

◆ sfp_status()

timing.cli.debug.sfp_status ( obj)

Definition at line 155 of file debug.py.

155def sfp_status(obj):
156 lDevice = obj.mDevice
157 lBoardType = obj.mBoardType
158
159 lNodes = []
160 lSwitches={}
161 lSwitchChannels={}
162 if lBoardType in [kBoardFMC, kBoardPC069]:
163 lNodes = ['io.sfp_i2c','io.uid_i2c','io.pll_i2c']
164 elif lBoardType == kBoardPC059:
165 lNodes = ['io.i2c', 'io.usfp_i2c']
166 switch_address=lDevice.getNode('io.i2c').get_slave_address('SFP_Switch')
167 lSwitches={"io.i2c": switch_address}
168 lSwitchChannels={"io.i2c": 8}
169 elif lBoardType in [kBoardTLU, kBoardMIB, kBoardGIB]:
170 lNodes = ['io.i2c']
171 if lBoardType == kBoardGIB:
172 lSwitches={"io.i2c": 0x70}
173 lSwitchChannels={"io.i2c": 7}
174 else:
175 secho(f"Error I don't know about board {lBoardType} : {kBoardNameMap[lBoardType]}", fg='red')
176 # if lBoardType == kBoardPC059:
177 # lSFPSwitch = lDevice.getNode('io.i2c').get_slave('SFP_Switch')
178 # print(lSFPSwitch.read_i2cPrimitive(1))
179 # print(lSFPSwitch.write_i2cPrimitive([0x1]))
180 # print(lSFPSwitch.read_i2cPrimitive(1))
181
182 for n in lNodes:
183 lI2CBusNode = lDevice.getNode(n)
184 echo('Scanning '+style(n,fg='cyan'))
185 lAddresses = lI2CBusNode.scan()
186 print(" '{}': {} devices found.\n Addresses: {}".format(n, len(lAddresses), ', '.join((hex(a) for a in lAddresses))))
187 if n in lSwitches:
188 print(f" Found {len(lSwitches)} switches.\n Addresses: {lSwitches.values()}")
189 for switch,address in lSwitches.items():
190 print (f"switch {switch} address: {address}")
191 switch_channels=lSwitchChannels[switch]
192 print(f"working with {switch}, @ adr {address}, it has {switch_channels} channels")
193 for channel in range(0,switch_channels):
194 secho(f"Scanning with channel {channel} enabled", fg='cyan')
195 lI2CBusNode.write_i2cPrimitive(address, [1<<channel])
196 lAddresses = lI2CBusNode.scan()
197 print(" '{}': {} devices found.\n Addresses: {}".format(n, len(lAddresses), ', '.join((hex(a) for a in lAddresses))))
198
199
200
201# ------------------------------------------------------------------------------
202
203@debug.command('fanout-sfp-scan', short_help="Debug.")
204@click.pass_obj

◆ sfpexpander()

timing.cli.debug.sfpexpander ( obj)

Definition at line 126 of file debug.py.

126def sfpexpander(obj):
127 lDevice = obj.mDevice
128 lBoardType = obj.mBoardType
129
130 if lBoardType != kBoardPC059:
131 secho('No SFP expander on {}'.format(kBoardNameMap[lBoardInfo['board_type'].value()]))
132 return
133 lI2CBusNode = lDevice.getNode("io.i2c")
134 lSFPExp = I2CExpanderSlave(lI2CBusNode, lI2CBusNode.get_slave('SFPExpander').get_i2c_address())
135 lSFPExpStatus = lSFPExp.debug()
136
137 lLabels = [
138 'B0 values',
139 'B1 values',
140 'B0 enable',
141 'B1 enable',
142 'B0 invert',
143 'B1 invert',
144 'B0 I/O ',
145 'B1 I/O ',
146 ]
147 for a,v in enumerate(lSFPExpStatus):
148 echo("{} ({}): {}".format(lLabels[a], hex(a), hex(v)))
149# ------------------------------------------------------------------------------
150
151
152# ------------------------------------------------------------------------------
153@debug.command('scan-i2c', short_help="Debug.")
154@click.pass_obj

◆ uuid()

timing.cli.debug.uuid ( obj)

Definition at line 94 of file debug.py.

94def uuid(obj):
95
96 lDevice = obj.mDevice
97 lBoardType = obj.mBoardType
98 lIO = lDevice.getNode('io')
99
100 # Detect the on-board eprom and read the board UID
101 if lBoardType in [kBoardPC059, kBoardTLU, kBoardMIB, kBoardGIB]:
102 lUID = lDevice.getNode('io.i2c')
103 else:
104 lUID = lDevice.getNode('io.uid_i2c')
105
106 lPROMSlave = 'UID_PROM' if lBoardType in [kBoardTLU,kBoardMIB,kBoardGIB] else 'FMC_UID_PROM'
107
108 if lBoardType == kBoardGIB:
109 lDevice.getNode("io.csr.ctrl.i2c_sw_rst").write(0x0)
110 lDevice.dispatch()
111 lDevice.getNode("io.csr.ctrl.i2c_sw_rst").write(0x1)
112 lDevice.dispatch()
113 lIO.set_i2c_mux_channels(0x1)
114
115 lValues = lUID.get_slave(lPROMSlave).read_i2cArray(0xfa, 6)
116 lUniqueID = 0x0
117 for lVal in lValues:
118 lUniqueID = ( lUniqueID << 8 ) | lVal
119 echo("Timing Board PROM UID: "+style(hex(lUniqueID), fg="blue"))
120# ------------------------------------------------------------------------------
121
122
123# ------------------------------------------------------------------------------
124@debug.command('sfpexpander', short_help="Debug.")
125@click.pass_obj