Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
python_test_scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
python_test_scripts
Commits
9680beff
Commit
9680beff
authored
4 years ago
by
Gijs Schoonderbeek
Browse files
Options
Downloads
Patches
Plain Diff
Step 2 in classification, added node class. Ready to check on HW
parent
4293a31e
No related branches found
No related tags found
1 merge request
!2
Modified the scripts to run on Raspberry Pi.
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
rd_unb2c.py
+157
-5
157 additions, 5 deletions
rd_unb2c.py
with
157 additions
and
5 deletions
rd_unb2c.py
+
157
−
5
View file @
9680beff
...
@@ -15,12 +15,143 @@ else:
...
@@ -15,12 +15,143 @@ else:
from
UniBoard2_I2C
import
*
from
UniBoard2_I2C
import
*
I2CBUSNR
=
3
I2CBUSNR
=
3
class
c_node
:
def
__int__
(
self
,
number
):
self
.
node_number
=
number
self
.
pols
=
[]
for
pol
in
list
(
LOC_POLS
.
keys
()):
self
.
pols
.
append
(
c_pol
(
pol
))
self
.
ddr
=
[]
for
bank_cnt
in
range
(
2
):
self
.
ddr
.
append
(
c_ddr
(
bank_cnt
))
self
.
qsfp
=
[]
for
qsfp_cnt
in
range
(
6
):
self
.
qsfp
.
append
(
c_qsfp
(
qsfp_cnt
))
def
read_all
(
self
):
for
pol
in
self
.
pols
:
pol
.
read_all
()
for
ddr
in
self
.
ddr
:
ddr
.
read_all
()
for
qsfp
in
self
.
qsfp
:
qsfp
.
read_all
()
def
print_status
(
self
):
for
pol
in
self
.
pols
:
pol
.
print_status
()
for
ddr
in
self
.
ddr
:
ddr
.
print_status
()
for
qsfp
in
self
.
qsfp
:
qsfp
.
print_status
()
def
set_i2c_switches
(
self
):
main_switch
=
I2C
(
MAIN_I2C_SWITCH
)
main_switch
.
bus
=
I2CBUSNR
ret_ack
=
main_switch
.
write_bytes
(
0x0
,
0x01
<<
self
.
node_number
)
# select Node
if
ret_ack
<
1
:
print
(
"
Main I2C switch not found
"
)
else
:
node_switch
=
I2C
(
NODE_I2C_SWITCH
)
node_switch
.
bus
=
I2CBUSNR
ret_ack
=
node_switch
.
write_bytes
(
0x0
,
0x20
)
# select DDR4
if
ret_ack
<
1
:
print
(
"
Node I2C switch not found
"
)
class
c_qsfp
:
def
__init__
(
self
,
port
):
self
.
port
=
port
self
.
temp
=
0
self
.
volt
=
0
self
.
status
=
False
def
select_qsfp
(
self
):
node_switch
=
I2C
(
NODE_I2C_SWITCH
)
node_switch
.
bus
=
I2CBUSNR
ret_ack
=
node_switch
.
write_bytes
(
0x0
,
QSFP_PORT
[
self
.
port
])
if
ret_ack
<
1
:
print
(
"
Node I2C switch not found
"
)
self
.
status
=
True
else
:
self
.
status
=
False
def
read_temp
(
selfs
):
ret_ack
,
raw_ret
=
QSFP_cage
.
read_bytes
(
QSFP_TEMP
,
2
)
if
ret_ack
<
1
:
self
.
status
=
False
else
:
ret_value
=
[]
ret_value
.
append
(
int
(
raw_ret
[:
2
],
16
))
ret_value
.
append
(
int
(
raw_ret
[
2
:],
16
))
self
.
temp
=
(
ret_value
[
0
]
*
256
+
ret_value
[
1
])
/
256
def
read_volt
(
selfs
):
ret_ack
,
raw_ret
=
QSFP_cage
.
read_bytes
(
QSFP_VOLT
,
2
)
if
ret_ack
<
1
:
self
.
status
=
False
else
:
ret_value
.
append
(
int
(
raw_ret
[:
2
],
16
))
ret_value
.
append
(
int
(
raw_ret
[
2
:],
16
))
self
.
volt
=
(
ret_value
[
0
]
*
256
+
ret_value
[
1
])
*
0.0001
def
read_all
(
self
):
self
.
read_temp
()
self
.
read_volt
()
def
print_status
(
self
):
if
self
.
status
:
stri
=
"
Slot {0} : QSFP Temperature QSFP {1:3.2f} gr. C Voltage {2:3.2f} V
"
.
format
(
self
.
port
self
.
temp
,
self
.
volt
)
print
(
stri
)
class
c_ddr
:
def
__init__
(
self
,
bank
):
self
.
bank
=
bank
if
self
.
bank
==
0
:
self
.
ddr_dev
=
I2C
(
MB_I_TEMP_I2C_ADDR
)
else
:
self
.
ddr_dev
=
I2C
(
MB_II_TEMP_I2C_ADDR
)
self
.
ddr_dev
.
bus
=
I2CBUSNR
def
set_i2c_switch
(
self
):
node_switch
=
I2C
(
NODE_I2C_SWITCH
)
node_switch
.
bus
=
I2CBUSNR
ret_ack
=
node_switch
.
write_bytes
(
0x0
,
DDR4
)
if
ret_ack
<
1
:
print
(
"
Node I2C switch not found
"
)
self
.
status
=
True
else
:
self
.
status
=
False
def
read_temp
(
self
):
ret_ack
,
raw_ret
=
self
.
ddr_dev
.
read_bytes
(
MB_TEMP_REG
,
2
)
if
ret_ack
<
1
:
stri
=
"
No DDR moduel in slot {0} node {1}
"
.
format
(
module
,
node_nr
)
else
:
ret_value
=
[]
ret_value
.
append
(
int
(
raw_ret
[:
2
],
16
))
ret_value
.
append
(
int
(
raw_ret
[
2
:],
16
))
temp
=
(((
ret_value
[
0
]
&
0x1F
)
*
0x100
)
+
(
ret_value
[
1
]
&
0xFC
))
*
0.0625
def
read_all
(
self
):
self
.
set_i2c_switch
()
self
.
read_temp
()
def
print_status
(
self
):
if
self
.
status
:
stri
=
"
Temperature DDR4 in slot {0} is {2:3.2f} C
"
.
format
(
self
.
bank
,
temp
)
print
(
stri
)
class
c_pol
:
class
c_pol
:
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
,
type
=
"
node
"
):
self
.
name
=
name
self
.
name
=
name
self
.
type
=
type
self
.
vout
=
0
self
.
vout
=
0
self
.
iout
=
0
self
.
iout
=
0
self
.
tem
=
0
self
.
tem
=
0
if
type
==
"
node
"
:
self
.
set_i2c_switch
()
self
.
pol_dev
=
I2C
(
LOC_POLS
[
self
.
name
])
self
.
pol_dev
=
I2C
(
LOC_POLS
[
self
.
name
])
self
.
pol_dev
.
bus
=
I2CBUSNR
self
.
pol_dev
.
bus
=
I2CBUSNR
sleep
(
0.1
)
sleep
(
0.1
)
...
@@ -32,8 +163,21 @@ class c_pol:
...
@@ -32,8 +163,21 @@ class c_pol:
else
:
else
:
self
.
status
=
True
self
.
status
=
True
def
set_i2c_switch
(
self
):
node_switch
=
I2C
(
NODE_I2C_SWITCH
)
node_switch
.
bus
=
I2CBUSNR
ret_ack
=
node_switch
.
write_bytes
(
0x0
,
LOC_POWER
)
if
ret_ack
<
1
:
print
(
"
Node I2C switch not found
"
)
self
.
status
=
True
else
:
self
.
status
=
False
def
read_vout
(
self
):
def
read_vout
(
self
):
if
self
.
status
:
if
self
.
status
:
if
type
==
"
node
"
:
self
.
set_i2c_switch
()
sleep
(
0.1
)
sleep
(
0.1
)
ret_ack
,
vout_mod
=
self
.
pol_dev
.
read_bytes
(
LP_VOUT_MODE
,
1
)
ret_ack
,
vout_mod
=
self
.
pol_dev
.
read_bytes
(
LP_VOUT_MODE
,
1
)
sleep
(
0.1
)
sleep
(
0.1
)
...
@@ -48,6 +192,8 @@ class c_pol:
...
@@ -48,6 +192,8 @@ class c_pol:
def
read_iout
(
self
):
def
read_iout
(
self
):
if
self
.
status
:
if
self
.
status
:
if
type
==
"
node
"
:
self
.
set_i2c_switch
()
sleep
(
0.1
)
sleep
(
0.1
)
ret_ack
,
raw_value
=
self
.
pol_dev
.
read_bytes
(
LP_IOUT
,
2
)
ret_ack
,
raw_value
=
self
.
pol_dev
.
read_bytes
(
LP_IOUT
,
2
)
ret_value
=
[]
ret_value
=
[]
...
@@ -59,6 +205,8 @@ class c_pol:
...
@@ -59,6 +205,8 @@ class c_pol:
def
read_temp
(
self
):
def
read_temp
(
self
):
if
self
.
status
:
if
self
.
status
:
if
type
==
"
node
"
:
self
.
set_i2c_switch
()
sleep
(
0.1
)
sleep
(
0.1
)
ret_ack
,
raw_value
=
self
.
pol_dev
.
read_bytes
(
LP_temp
,
2
)
ret_ack
,
raw_value
=
self
.
pol_dev
.
read_bytes
(
LP_temp
,
2
)
ret_value
=
[]
ret_value
=
[]
...
@@ -75,7 +223,7 @@ class c_pol:
...
@@ -75,7 +223,7 @@ class c_pol:
def
print_status
(
self
):
def
print_status
(
self
):
if
self
.
status
:
if
self
.
status
:
self
.
read_all
()
#
self.read_all()
stri
=
"
POL:
"
+
self
.
name
+
"
"
stri
=
"
POL:
"
+
self
.
name
+
"
"
stri
+=
"
Output voltage :{0: <5.2f} V
"
.
format
(
self
.
vout
)
stri
+=
"
Output voltage :{0: <5.2f} V
"
.
format
(
self
.
vout
)
stri
+=
"
Output Current :{0: <5.2f} A
"
.
format
(
self
.
iout
)
stri
+=
"
Output Current :{0: <5.2f} A
"
.
format
(
self
.
iout
)
...
@@ -258,6 +406,10 @@ else:
...
@@ -258,6 +406,10 @@ else:
ret_ack
=
node_switch
.
write_bytes
(
0x0
,
0x20
)
#select DDR4
ret_ack
=
node_switch
.
write_bytes
(
0x0
,
0x20
)
#select DDR4
if
ret_ack
<
1
:
if
ret_ack
<
1
:
print
(
"
Node I2C switch not found
"
)
print
(
"
Node I2C switch not found
"
)
for
pol
in
list
(
LOC_POLS
.
keys
()):
polletje
=
c_pol
(
pol
)
node
=
c_node
(
0
)
polletje
.
print_status
()
node
.
read_all
()
node
.
print_status
()
#for pol in list(LOC_POLS.keys()):
# polletje = c_pol(pol)
# polletje.print_status()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment