Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
scouting-demonstrator
SCONE
Commits
f3590ad8
Commit
f3590ad8
authored
Oct 29, 2021
by
Dinyar Rabady
Browse files
Change location keyword to address
This was done to make the address table a bit closer to the firmware. Belongs to
#22
.
parent
d6324da3
Changes
13
Hide whitespace changes
Inline
Side-by-side
MonitoringTools/prometheus_monitoring.py
View file @
f3590ad8
...
...
@@ -34,20 +34,20 @@ def monitoring_board(config_json, board, metrics, device, previous_read_values,
for
reg
in
config_json
[
board
][
"registers"
]:
exposable
=
config_json
[
board
][
"registers"
][
reg
][
"exposable"
]
if
not
exposable
:
continue
location
=
config_json
[
board
][
"registers"
][
reg
][
"
location
"
]
address
=
config_json
[
board
][
"registers"
][
reg
][
"
address
"
]
width
=
config_json
[
board
][
"registers"
][
reg
][
"width"
]
offset
=
config_json
[
board
][
"registers"
][
reg
][
"offset"
]
metric
=
config_json
[
board
][
"registers"
][
reg
][
"metric"
]
read_val
=
rw
.
ReadProperty
(
device
,
location
,
offset
,
width
,
verbose
=
verbose
,
logging
=
logging
)
read_val
=
rw
.
ReadProperty
(
device
,
address
,
offset
,
width
,
verbose
=
verbose
,
logging
=
logging
)
if
logging
!=
None
:
logging
.
info
(
"%s
\t
loc: %s
\t
offset: %s
\t
width: %s
\t
--> value: %i (%s)"
%
(
reg
,
location
,
offset
,
width
,
read_val
,
bin
(
read_val
)))
logging
.
info
(
"%s
\t
loc: %s
\t
offset: %s
\t
width: %s
\t
--> value: %i (%s)"
%
(
reg
,
address
,
offset
,
width
,
read_val
,
bin
(
read_val
)))
if
dump
:
print
(
"%s
\t
loc: %s
\t
offset: %s
\t
width: %s
\t
--> value: %i (%s)"
%
(
reg
,
location
,
offset
,
width
,
read_val
,
bin
(
read_val
)))
print
(
"%s
\t
loc: %s
\t
offset: %s
\t
width: %s
\t
--> value: %i (%s)"
%
(
reg
,
address
,
offset
,
width
,
read_val
,
bin
(
read_val
)))
try
:
update_metric
(
metrics
[
metric
],
metric_type
=
metric
,
value
=
read_val
,
register
=
reg
,
board
=
board
,
previous_read_values
=
previous_read_values
,
logging
=
logging
)
except
Exception
as
e
:
print
(
"Unknown metric: %s; available metrics are 'gauge' and 'counter'"
%
(
e
))
update_history
(
previous_values
=
previous_read_values
,
register
=
reg
,
value
=
read_val
)
del
location
,
width
,
offset
,
metric
,
read_val
del
address
,
width
,
offset
,
metric
,
read_val
gc
.
collect
()
return
README.md
View file @
f3590ad8
...
...
@@ -25,13 +25,13 @@
'register_name1' : {
width : 32
offset : 0
location
: '0x0'
address
: '0x0'
metric : 'gauge'
},
'register_name2' : {
width : 32
offset : 0
location
: '0x4'
address
: '0x4'
metric : 'counter'
},
}
...
...
ReadWriteTools/rw.py
View file @
f3590ad8
...
...
@@ -8,12 +8,12 @@ import gc
so_file
=
"./ReadWriteTools/functions.so"
cfunc
=
ctypes
.
CDLL
(
so_file
)
def
ReadProperty
(
device
,
location
,
offset
,
width
,
logging
=
None
,
verbose
=
False
):
def
ReadProperty
(
device
,
address
,
offset
,
width
,
logging
=
None
,
verbose
=
False
):
device_c
=
ctypes
.
c_char_p
(
device
.
encode
(
'utf-8'
))
location
_c
=
ctypes
.
c_char_p
(
location
.
encode
(
'utf-8'
))
address
_c
=
ctypes
.
c_char_p
(
address
.
encode
(
'utf-8'
))
verbose_c
=
ctypes
.
c_uint
(
verbose
)
read_32bits
=
ctypes
.
c_uint
(
0
)
isRead
=
cfunc
.
read_bits
(
device_c
,
location
_c
,
ctypes
.
byref
(
read_32bits
),
verbose_c
)
isRead
=
cfunc
.
read_bits
(
device_c
,
address
_c
,
ctypes
.
byref
(
read_32bits
),
verbose_c
)
if
isRead
==
-
1
:
logging
.
error
(
"An error occured while executing C function read_bits"
)
return
-
1
...
...
@@ -21,18 +21,18 @@ def ReadProperty(device, location, offset, width, logging=None, verbose=False):
logging
.
debug
(
"Read: %s"
%
(
string_32bits
))
mask
=
2
**
width
-
1
output
=
(
read_32bits
.
value
>>
offset
)
&
mask
# convert selected string to integer
del
read_32bits
,
isRead
,
string_32bits
,
mask
,
device_c
,
location
_c
,
verbose_c
del
read_32bits
,
isRead
,
string_32bits
,
mask
,
device_c
,
address
_c
,
verbose_c
gc
.
collect
()
logging
.
debug
(
"Unmasked result: %i (%s)"
%
(
output
,
str
(
bin
(
output
))))
return
output
def
WriteProperty
(
device
,
location
,
offset
,
width
,
value
,
logging
=
None
,
verbose
=
False
):
def
WriteProperty
(
device
,
address
,
offset
,
width
,
value
,
logging
=
None
,
verbose
=
False
):
device_c
=
ctypes
.
c_char_p
(
device
.
encode
(
'utf-8'
))
location
_c
=
ctypes
.
c_char_p
(
location
.
encode
(
'utf-8'
))
address
_c
=
ctypes
.
c_char_p
(
address
.
encode
(
'utf-8'
))
verbose_c
=
ctypes
.
c_uint
(
verbose
)
read_value
=
ctypes
.
c_uint
(
0
);
write_value
=
ctypes
.
c_uint
(
value
)
isRead
=
cfunc
.
read_bits
(
device_c
,
location
_c
,
ctypes
.
byref
(
read_value
),
verbose_c
)
isRead
=
cfunc
.
read_bits
(
device_c
,
address
_c
,
ctypes
.
byref
(
read_value
),
verbose_c
)
if
isRead
==
-
1
:
logging
.
error
(
"An error occured while executing C function read_bits"
)
return
-
1
...
...
@@ -43,26 +43,26 @@ def WriteProperty(device, location, offset, width, value, logging=None, verbose=
mask
=
(
2
**
width
-
1
)
<<
offset
notmask
=
(
2
**
32
-
1
)
-
mask
output
=
((
write_value
.
value
<<
offset
)
&
mask
)
|
(
read_value
.
value
&
notmask
)
isWritten
=
cfunc
.
write_bits
(
device_c
,
location
_c
,
output
,
verbose_c
)
isWritten
=
cfunc
.
write_bits
(
device_c
,
address
_c
,
output
,
verbose_c
)
if
isWritten
==
-
1
:
logging
.
error
(
"An error occured while executing C function write_bits."
)
del
read_value
,
isRead
,
string_read
,
string_write
,
mask
,
notmask
,
output
,
device_c
,
location
_c
,
verbose_c
del
read_value
,
isRead
,
string_read
,
string_write
,
mask
,
notmask
,
output
,
device_c
,
address
_c
,
verbose_c
gc
.
collect
()
return
-
1
# Readback as checkout
isReadcheck
=
cfunc
.
read_bits
(
device_c
,
location
_c
,
ctypes
.
byref
(
read_value
),
verbose_c
)
isReadcheck
=
cfunc
.
read_bits
(
device_c
,
address
_c
,
ctypes
.
byref
(
read_value
),
verbose_c
)
if
isReadcheck
==
-
1
:
logging
.
error
(
"An error occured while executing C function read_bits"
)
del
read_value
,
isRead
,
isReadcheck
,
string_read
,
string_write
,
mask
,
notmask
,
output
,
device_c
,
location
_c
,
verbose_c
del
read_value
,
isRead
,
isReadcheck
,
string_read
,
string_write
,
mask
,
notmask
,
output
,
device_c
,
address
_c
,
verbose_c
gc
.
collect
()
return
-
1
if
read_value
.
value
==
output
:
del
read_value
,
isRead
,
isReadcheck
,
string_read
,
string_write
,
mask
,
notmask
,
output
,
device_c
,
location
_c
,
verbose_c
del
read_value
,
isRead
,
isReadcheck
,
string_read
,
string_write
,
mask
,
notmask
,
output
,
device_c
,
address
_c
,
verbose_c
gc
.
collect
()
return
0
else
:
logging
.
error
(
"Readback failed. Register not writable."
)
logging
.
error
(
"Check the reading permission for
location
%s on board %s"
%
(
location
,
device
))
del
read_value
,
isRead
,
isReadcheck
,
string_read
,
string_write
,
mask
,
notmask
,
output
,
device_c
,
location
_c
,
verbose_c
logging
.
error
(
"Check the reading permission for
address
%s on board %s"
%
(
address
,
device
))
del
read_value
,
isRead
,
isReadcheck
,
string_read
,
string_write
,
mask
,
notmask
,
output
,
device_c
,
address
_c
,
verbose_c
gc
.
collect
()
return
-
1
address_table/CreateJsonFromDictionary.py
View file @
f3590ad8
...
...
@@ -36,7 +36,7 @@ if __name__ == '__main__':
'''basic address table with 32 registers 32 bits each
'''
for
m
in
monitorables
:
HandleRegisters
(
config_dict
,
action
=
'add'
,
board
=
'kcu1500'
,
register
=
m
[
0
],
width
=
m
[
1
],
offset
=
m
[
2
],
location
=
f
"0x
{
m
[
3
]
*
4
+
64
:
x
}
"
,
metric
=
m
[
4
],
writable
=
int
(
m
[
5
]),
exposable
=
int
(
m
[
6
]))
HandleRegisters
(
config_dict
,
action
=
'add'
,
board
=
'kcu1500'
,
register
=
m
[
0
],
width
=
m
[
1
],
offset
=
m
[
2
],
address
=
f
"0x
{
m
[
3
]
*
4
+
64
:
x
}
"
,
metric
=
m
[
4
],
writable
=
int
(
m
[
5
]),
exposable
=
int
(
m
[
6
]))
with
open
(
'address_table_kcu1500_64shift_rw.json'
,
'w'
)
as
outfile
:
json
.
dump
(
config_dict
,
outfile
,
indent
=
4
)
address_table/CreateJsonFromDictionaryProgrammatically.py
View file @
f3590ad8
...
...
@@ -34,7 +34,7 @@ if __name__ == '__main__':
'''basic address table with 32 registers 32 bits each
'''
for
m
in
monitorables
:
HandleRegisters
(
config_dict
,
action
=
'add'
,
board
=
'kcu1500'
,
register
=
m
[
0
],
width
=
m
[
1
],
offset
=
m
[
2
],
location
=
f
"0x
{
m
[
3
]
*
4
:
x
}
"
,
metric
=
m
[
4
])
HandleRegisters
(
config_dict
,
action
=
'add'
,
board
=
'kcu1500'
,
register
=
m
[
0
],
width
=
m
[
1
],
offset
=
m
[
2
],
address
=
f
"0x
{
m
[
3
]
*
4
:
x
}
"
,
metric
=
m
[
4
])
with
open
(
'address_table_kcu1500.json'
,
'w'
)
as
outfile
:
json
.
dump
(
config_dict
,
outfile
,
indent
=
4
)
address_table/HandleRegisters.py
View file @
f3590ad8
...
...
@@ -2,10 +2,10 @@ import json
import
logging
import
argparse
def
HandleRegisters
(
config_json
,
action
,
board
,
register
,
width
=
None
,
offset
=
None
,
metric
=
None
,
writable
=
False
,
exposable
=
False
,
location
=
None
,
logging
=
None
):
def
HandleRegisters
(
config_json
,
action
,
board
,
register
,
width
=
None
,
offset
=
None
,
metric
=
None
,
writable
=
False
,
exposable
=
False
,
address
=
None
,
logging
=
None
):
if
action
==
'add'
:
if
width
==
None
or
offset
==
None
or
location
==
None
:
logging
.
error
(
'
location
(-l), width (-w) and offset (-o) are required to add a new register.'
)
if
width
==
None
or
offset
==
None
or
address
==
None
:
logging
.
error
(
'
address
(-l), width (-w) and offset (-o) are required to add a new register.'
)
exit
()
if
register
in
config_json
[
board
][
'registers'
]:
logging
.
error
(
'register %s already configured in board %s; it cannot be added. Try action modify instead.'
%
(
register
,
board
))
...
...
@@ -21,7 +21,7 @@ def HandleRegisters(config_json, action, board, register, width=None, offset=Non
exit
()
config_json
[
board
][
'registers'
][
register
]
=
{
'width'
:
width
,
'
location'
:
location
,
'
address'
:
address
,
'offset'
:
offset
,
'metric'
:
metric
,
'writable'
:
writable
,
...
...
@@ -35,8 +35,8 @@ def HandleRegisters(config_json, action, board, register, width=None, offset=Non
config_json
[
board
][
'registers'
].
pop
(
register
)
elif
action
==
'modify'
:
if
width
==
None
or
offset
==
None
or
location
==
None
:
logging
.
error
(
'new values for
location
(-l), width (-w) and offset (-o) are required to add a new register.'
)
if
width
==
None
or
offset
==
None
or
address
==
None
:
logging
.
error
(
'new values for
address
(-l), width (-w) and offset (-o) are required to add a new register.'
)
exit
()
if
offset
>
31
or
offset
<
0
:
logging
.
error
(
'offset must be an integer between 0 and 31. Register %s was not updated.'
%
(
register
))
...
...
@@ -50,7 +50,7 @@ def HandleRegisters(config_json, action, board, register, width=None, offset=Non
if
not
register
in
config_json
[
board
][
'registers'
]:
logging
.
error
(
'register %s in board %s not configured yet; adding it.'
%
(
register
,
board
))
config_json
[
board
][
'registers'
][
register
]
=
{
'width'
:
width
,
'
location'
:
location
,
'
address'
:
address
,
'offset'
:
offset
,
'metric'
:
metric
,
'writable'
:
writable
,
...
...
@@ -58,7 +58,7 @@ def HandleRegisters(config_json, action, board, register, width=None, offset=Non
}
else
:
config_json
[
board
][
'registers'
][
register
][
'width'
]
=
width
config_json
[
board
][
'registers'
][
register
][
'
location'
]
=
location
config_json
[
board
][
'registers'
][
register
][
'
address'
]
=
address
config_json
[
board
][
'registers'
][
register
][
'offset'
]
=
offset
config_json
[
board
][
'registers'
][
register
][
'metric'
]
=
metric
config_json
[
board
][
'registers'
][
register
][
'writable'
]
=
writable
...
...
@@ -77,7 +77,7 @@ if __name__ == '__main__':
parser
.
add_argument
(
'-m'
,
'--metric'
,
type
=
str
,
help
=
"new metric type"
,
required
=
False
,
choices
=
[
'gauge'
,
'counter'
,
None
])
parser
.
add_argument
(
'-i'
,
'--iswritable'
,
type
=
bool
,
help
=
"is writable"
,
required
=
False
,
default
=
False
)
parser
.
add_argument
(
'-e'
,
'--exposable'
,
type
=
bool
,
help
=
"to be exposed"
,
required
=
False
,
default
=
False
)
parser
.
add_argument
(
'-l'
,
'--
location
'
,
type
=
str
,
help
=
"new
location
"
,
required
=
False
)
parser
.
add_argument
(
'-l'
,
'--
address
'
,
type
=
str
,
help
=
"new
address
"
,
required
=
False
)
parser
.
add_argument
(
'-f'
,
'--filelog'
,
type
=
str
,
help
=
"logfile"
,
required
=
False
)
parser
.
add_argument
(
'-d'
,
'--dump'
,
type
=
int
,
help
=
"dump messages"
,
required
=
False
,
default
=
0
)
...
...
@@ -94,7 +94,7 @@ if __name__ == '__main__':
width
=
args
.
width
offset
=
args
.
offset
metric
=
args
.
metric
location
=
args
.
location
address
=
args
.
address
exposable
=
args
.
exposable
writable
=
args
.
iswritable
if
not
board
in
config_json
:
...
...
@@ -107,7 +107,7 @@ if __name__ == '__main__':
exit
()
logging
.
info
(
'Action: %s
\n
'
%
(
action
))
HandleRegisters
(
config_json
,
action
,
board
,
register
,
width
=
width
,
offset
=
offset
,
metric
=
metric
,
writable
=
writable
,
exposable
=
exposable
,
location
=
location
,
logging
=
logging
)
HandleRegisters
(
config_json
,
action
,
board
,
register
,
width
=
width
,
offset
=
offset
,
metric
=
metric
,
writable
=
writable
,
exposable
=
exposable
,
address
=
address
,
logging
=
logging
)
with
open
(
args
.
jsonfile
,
'w'
)
as
jsonfile
:
json
.
dump
(
config_json
,
jsonfile
,
indent
=
4
)
...
...
address_table/address_table_kcu1500.json
View file @
f3590ad8
...
...
@@ -4,124 +4,124 @@
"registers"
:
{
"cdr_stable"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
0
,
"metric"
:
"gauge"
},
"RxByteIsAligned"
:
{
"width"
:
8
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
1
,
"metric"
:
"gauge"
},
"GtPowerGood"
:
{
"width"
:
8
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
9
,
"metric"
:
"gauge"
},
"GtTxResetDone"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
17
,
"metric"
:
"gauge"
},
"GtRxResetDone"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
18
,
"metric"
:
"gauge"
},
"TxPmaResetDone"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
19
,
"metric"
:
"gauge"
},
"RxPmaResetDone"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
20
,
"metric"
:
"gauge"
},
"GtResetTxPllDatapath"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
21
,
"metric"
:
"gauge"
},
"GtResetTxDatapath"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
22
,
"metric"
:
"gauge"
},
"GtResetRxDatapath"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
23
,
"metric"
:
"gauge"
},
"InitDone"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
24
,
"metric"
:
"gauge"
},
"FreqInput"
:
{
"width"
:
32
,
"
location
"
:
"0x44"
,
"
address
"
:
"0x44"
,
"offset"
:
0
,
"metric"
:
"gauge"
},
"FillerOrbitsSeen"
:
{
"width"
:
32
,
"
location
"
:
"0x48"
,
"
address
"
:
"0x48"
,
"offset"
:
0
,
"metric"
:
"counter"
},
"FillerOrbitsDropped"
:
{
"width"
:
32
,
"
location
"
:
"0x4c"
,
"
address
"
:
"0x4c"
,
"offset"
:
0
,
"metric"
:
"counter"
},
"AxiBackpressureSeen"
:
{
"width"
:
1
,
"
location
"
:
"0x50"
,
"
address
"
:
"0x50"
,
"offset"
:
0
,
"metric"
:
"gauge"
},
"OrbitExceedsSize"
:
{
"width"
:
1
,
"
location
"
:
"0x50"
,
"
address
"
:
"0x50"
,
"offset"
:
1
,
"metric"
:
"gauge"
},
"WaitingForOrbitEnd"
:
{
"width"
:
1
,
"
location
"
:
"0x50"
,
"
address
"
:
"0x50"
,
"offset"
:
2
,
"metric"
:
"gauge"
},
"I2CvalueRead"
:
{
"width"
:
8
,
"
location
"
:
"0x50"
,
"
address
"
:
"0x50"
,
"offset"
:
3
,
"metric"
:
"gauge"
},
"Autorealigns"
:
{
"width"
:
32
,
"
location
"
:
"0x54"
,
"
address
"
:
"0x54"
,
"offset"
:
0
,
"metric"
:
"counter"
},
"OrbitLength"
:
{
"width"
:
32
,
"
location
"
:
"0x58"
,
"
address
"
:
"0x58"
,
"offset"
:
0
,
"metric"
:
"gauge"
}
}
}
}
\ No newline at end of file
}
address_table/address_table_kcu1500_64shift.json
View file @
f3590ad8
...
...
@@ -4,124 +4,124 @@
"registers"
:
{
"cdr_stable"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
0
,
"metric"
:
"gauge"
},
"RxByteIsAligned"
:
{
"width"
:
8
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
1
,
"metric"
:
"gauge"
},
"GtPowerGood"
:
{
"width"
:
8
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
9
,
"metric"
:
"gauge"
},
"GtTxResetDone"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
17
,
"metric"
:
"gauge"
},
"GtRxResetDone"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
18
,
"metric"
:
"gauge"
},
"TxPmaResetDone"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
19
,
"metric"
:
"gauge"
},
"RxPmaResetDone"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
20
,
"metric"
:
"gauge"
},
"GtResetTxPllDatapath"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
21
,
"metric"
:
"gauge"
},
"GtResetTxDatapath"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
22
,
"metric"
:
"gauge"
},
"GtResetRxDatapath"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
23
,
"metric"
:
"gauge"
},
"InitDone"
:
{
"width"
:
1
,
"
location
"
:
"0x40"
,
"
address
"
:
"0x40"
,
"offset"
:
24
,
"metric"
:
"gauge"
},
"FreqInput"
:
{
"width"
:
32
,
"
location
"
:
"0x44"
,
"
address
"
:
"0x44"
,
"offset"
:
0
,
"metric"
:
"counter"
},
"FillerOrbitsSeen"
:
{
"width"
:
32
,
"
location
"
:
"0x48"
,
"
address
"
:
"0x48"
,
"offset"
:
0
,
"metric"
:
"counter"
},
"FillerOrbitsDropped"
:
{
"width"
:
32
,
"
location
"
:
"0x4c"
,
"
address
"
:
"0x4c"
,
"offset"
:
0
,
"metric"
:
"counter"
},
"AxiBackpressureSeen"
:
{
"width"
:
1
,
"
location
"
:
"0x50"
,
"
address
"
:
"0x50"
,
"offset"
:
0
,
"metric"
:
"gauge"
},
"OrbitExceedsSize"
:
{
"width"
:
1
,
"
location
"
:
"0x50"
,
"
address
"
:
"0x50"
,
"offset"
:
1
,
"metric"
:
"gauge"
},
"WaitingForOrbitEnd"
:
{
"width"
:
1
,
"
location
"
:
"0x50"
,
"
address
"
:
"0x50"
,
"offset"
:
2
,
"metric"
:
"counter"
},
"I2CvalueRead"
:
{
"width"
:
8
,
"
location
"
:
"0x50"
,
"
address
"
:
"0x50"
,
"offset"
:
3
,
"metric"
:
"gauge"
},
"Autorealigns"
:
{
"width"
:
32
,
"
location
"
:
"0x54"
,
"
address
"
:
"0x54"
,
"offset"
:
0
,
"metric"
:
"counter"
},
"OrbitLength"
:
{
"width"
:
32
,
"
location
"
:
"0x58"
,
"
address
"
:
"0x58"
,
"offset"
:
0
,
"metric"
:
"counter"
}
}
}
}
\ No newline at end of file
}
address_table/addrtab_example.json
View file @
f3590ad8
...
...
@@ -3,17 +3,17 @@
"registers"
:
{
"register0"
:
{
"width"
:
10
,
"
location
"
:
"0x00000000"
,
"
address
"
:
"0x00000000"
,
"offset"
:
0
},
"register1"
:
{
"width"
:
20
,
"
location
"
:
"0x00000000"
,
"
address
"
:
"0x00000000"
,
"offset"
:
10
},
"register10"
:
{
"width"
:
16
,
"
location
"
:
"0x00000000"
,
"
address
"
:
"0x00000000"
,
"offset"
:
2
}
},
...
...
@@ -23,12 +23,12 @@
"registers"
:
{
"register0"
:
{
"width"
:
32
,
"
location
"
:
"0x00000000"
,
"
address
"
:
"0x00000000"
,
"offset"
:
0
},
"register1"
:
{
"width"
:
2
,
"
location
"
:
"0x00000004"
,
"
address
"
:
"0x00000004"
,
"offset"
:
30
}
},
...
...
address_table/addrtab_to_vhdl.py
View file @
f3590ad8
...
...
@@ -23,7 +23,7 @@ def main(addrtab, reg_name):
f
.
write
(
vhdl_header
)
for
reg
in
registers
:
reg_info
=
registers
[
reg
]
f
.
write
(
'constant '
+
reg
+
'_addr : natural := '
+
str
(
int
(
reg_info
[
'
location
'
],
16
)
//
4
)
+
';
\n
'
)
f
.
write
(
'constant '
+
reg
+
'_addr : natural := '
+
str
(
int
(
reg_info
[
'
address
'
],
16
)
//
4
)
+
';
\n
'
)
f
.
write
(
'constant '
+
reg
+
'_offset : natural := '
+
str
(
reg_info
[
'offset'
])
+
';
\n
'
)
f
.
write
(
'constant '
+
reg
+
'_width : natural := '
+
str
(
reg_info
[
'width'
])
+
';
\n
'
)
f
.
write
(
vhdl_trailer
)
...
...
l1scout_monitoring.py
View file @
f3590ad8
...
...
@@ -65,15 +65,15 @@ def update_history(dictionary, register, value):
def
monitoring_board
(
config_json
,
board
,
metrics
,
device
,
previous_read_values
,
dump
=
0
,
verbose
=
False
,
logging
=
None
):
for
reg
in
config_json
[
board
][
"registers"
]:
location
=
config_json
[
board
][
"registers"
][
reg
][
"
location
"
]
address
=
config_json
[
board
][
"registers"
][
reg
][
"
address
"
]
width
=
config_json
[
board
][
"registers"
][
reg
][
"width"
]
offset
=
config_json
[
board
][
"registers"
][
reg
][
"offset"
]
metric
=
config_json
[
board
][
"registers"
][
reg
][
"metric"
]
read_val
=
rw
.
ReadProperty
(
device
,
location
,
offset
,
width
,
verbose
=
verbose
,
logging
=
logging
)
read_val
=
rw
.
ReadProperty
(
device
,
address
,
offset
,
width
,
verbose
=
verbose
,
logging
=
logging
)
logging
.
info
(
"%s
\t
loc: %s
\t
offset: %s
\t
width: %s
\t
--> value: %i (%s)"
%
(
reg
,
location
,
offset
,
width
,
read_val
,
bin
(
read_val
)))
logging
.
info
(
"%s
\t
loc: %s
\t
offset: %s
\t
width: %s
\t
--> value: %i (%s)"
%
(
reg
,
address
,
offset
,
width
,
read_val
,
bin
(
read_val
)))
if
dump
:
print
(
"%s
\t
loc: %s
\t
offset: %s
\t
width: %s
\t
--> value: %i (%s)"
%
(
reg
,
location
,
offset
,
width
,
read_val
,
bin
(
read_val
)))
print
(
"%s
\t
loc: %s
\t
offset: %s
\t
width: %s
\t
--> value: %i (%s)"
%
(
reg
,
address
,
offset
,
width
,
read_val
,
bin
(
read_val
)))
isUpdate
=
update_metric
(
metrics
[
metric
],
metric_type
=
metric
,
value
=
read_val
,
register
=
reg
,
previous_read_values
=
previous_read_values
)
if
isUpdate
==-
2
:
...
...
@@ -82,7 +82,7 @@ def monitoring_board(config_json, board, metrics, device, previous_read_values,
logging
.
info
(
'Counter %s on board %s has been reset'
%
(
reg
,
board
))
update_history
(
dictionary
=
previous_read_values
,
register
=
reg
,
value
=
read_val
)
del
location
,
width
,
offset
,
metric
,
read_val
,
isUpdate
del
address
,
width
,
offset
,
metric
,
read_val
,
isUpdate