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
a35a4729
Commit
a35a4729
authored
May 11, 2021
by
Gijs Schoonderbeek
Browse files
Options
Downloads
Patches
Plain Diff
Third step in classification
parent
c980ab71
No related branches found
No related tags found
1 merge request
!2
Modified the scripts to run on Raspberry Pi.
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
UniBoard2_I2C.py
+5
-0
5 additions, 0 deletions
UniBoard2_I2C.py
rd_unb2c.py
+93
-25
93 additions, 25 deletions
rd_unb2c.py
with
98 additions
and
25 deletions
UniBoard2_I2C.py
+
5
−
0
View file @
a35a4729
...
...
@@ -25,6 +25,11 @@ CTR_POWER_S_1V2 = 0x0F
CTR_POWER_CLK
=
0x0D
CTR_POWER_QSFP_01
=
0x01
CTR_POWER_QSFP_23
=
0x02
CTR_POLS
=
{
"
CTR_POWER_S_1V0
"
:
0x0E
,
"
CTR_POWER_S_1V2
"
:
0x0F
,
"
CTR_POWER_CLK
"
:
0x0D
,
"
CTR_POWER_QSFP_01
"
:
0x01
,
"
CTR_POWER_QSFP_23
"
:
0x02
}
LP_VOUT_MODE
=
0x20
LP_VOUT
=
0x8B
#
...
...
This diff is collapsed.
Click to expand it.
rd_unb2c.py
+
93
−
25
View file @
a35a4729
...
...
@@ -15,6 +15,72 @@ else:
from
UniBoard2_I2C
import
*
I2CBUSNR
=
3
class
c_unb2c
:
def
__init
(
self
):
self
.
status
=
False
self
.
nodes
=
[]
self
.
pols
=
[]
for
node_cnt
in
range
(
4
):
self
.
nodes
.
append
(
c_node
(
node_cnt
))
for
pol
in
list
(
CTR_POLS
.
keys
()):
self
.
pols
.
append
(
c_pol
(
pol
))
self
.
dev_i2c_eeprom
=
I2C
(
EEPROM
)
self
.
dev_i2c_eeprom
=
I2CBUSNR
def
write_eeprom
(
self
,
data
=
0x01
):
ret_ack
,
ret_value
=
self
.
dev_i2c_eeprom
.
read_bytes
(
0
)
if
ret_ack
<
1
:
print
(
"
no device found
"
)
else
:
self
.
dev_i2c_eeprom
.
write_bytes
(
0x00
,
data
)
def
read_eeprom
(
self
,
data
):
ret_ack
,
ret_value
=
self
.
dev_i2c_eeprom
.
read_bytes
(
0
)
if
ret_ack
<
1
:
print
(
"
no device found
"
)
else
:
self
.
dev_i2c_eeprom
.
write_bytes
(
0x00
,
value
)
ret_ack
,
ret_value
=
I2C_eeprom
.
read_bytes
(
0x00
,
1
)
return
ret_value
def
wr_rd_eeprom
(
self
):
self
.
write_eeprom
(
0x12
)
ret_value
=
self
.
read_eeprom
()
stri
=
"
Wrote to EEPROM: 0x{0:X}, Read from EEPROM: 0x{1}
"
.
format
(
value
,
ret_value
)
print
(
stri
)
def
front_led
(
collor
):
main_switch
=
I2C
(
MAIN_I2C_SWITCH
)
main_switch
.
bus
=
I2CBUSNR
ret_ack
=
main_switch
.
write_bytes
(
0x20
,
0x20
)
#select LED
if
ret_ack
<
1
:
print
(
"
Main I2C switch not found
"
)
else
:
front
=
I2C
(
LED_DRIVER
)
front
.
bus
=
I2CBUSNR
ret_ack
=
front
.
write_bytes
(
0x03
,
0
)
if
ret_ack
<
1
:
print
(
"
Front LED driver not found
"
)
else
:
front
.
write_bytes
(
0x01
,
collor
)
def
read_all
(
self
):
for
node
in
self
.
nodes
:
node
.
read_all
()
for
pol
in
self
.
nodes
:
pol
.
read_all
()
def
print_status
(
self
):
for
color
in
list
(
LED_COLORS
.
keys
()):
print
(
color
)
self
.
front_led
(
LED_COLORS
[
color
])
for
node
in
self
.
nodes
:
node
.
print_status
()
for
pol
in
self
.
nodes
:
pol
.
print_status
()
self
.
wr_rd_eeprom
()
class
c_node
:
def
__init__
(
self
,
number
):
self
.
node_number
=
number
...
...
@@ -39,6 +105,8 @@ class c_node:
qsfp
.
read_all
()
def
print_status
(
self
):
stri
=
"
Status of Node {0}
"
.
format
(
self
.
node_number
)
print
(
stri
)
for
pol
in
self
.
pols
:
pol
.
print_status
()
for
ddr
in
self
.
ddr
:
...
...
@@ -98,8 +166,8 @@ class c_qsfp:
self
.
select_qsfp
()
ret_ack
,
raw_ret
=
self
.
qsfp_cage
.
read_bytes
(
QSFP_VOLT
,
2
)
if
(
ret_ack
<
1
)
|
(
raw_ret
[:
2
]
==
'
ff
'
)
:
stri
=
"
No QSFP found in port {0}
"
.
format
(
self
.
port
)
print
(
stri
)
#
stri = "No QSFP found in port {0}".format(self.port)
#
print(stri)
self
.
status
=
False
else
:
ret_value
=
[]
...
...
@@ -176,8 +244,8 @@ class c_pol:
sleep
(
0.1
)
ret_ack
,
ret_value
=
self
.
pol_dev
.
read_bytes
(
0
)
if
ret_ack
<
1
:
stri
=
"
Device {0} at address 0x{1:X} not found
"
.
format
(
self
.
name
,
LOC_POLS
[
self
.
name
])
print
(
stri
)
#
stri = " Device {0} at address 0x{1:X} not found".format(self.name, LOC_POLS[self.name])
#
print(stri)
self
.
status
=
False
else
:
self
.
status
=
True
...
...
@@ -414,22 +482,22 @@ if 0:
read_pol
(
node_cnt
,
LOC_POWER_CORE
)
# read_pol(-1,0x01)
main_switch
=
I2C
(
MAIN_I2C_SWITCH
)
main_switch
.
bus
=
I2CBUSNR
ret_ack
=
main_switch
.
write_bytes
(
0x0
,
0x01
)
#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
"
)
#
main_switch = I2C(MAIN_I2C_SWITCH)
#
main_switch.bus = I2CBUSNR
#
ret_ack = main_switch.write_bytes(0x0, 0x01) #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")
for
cnt
in
range
(
2
):
node
=
c_node
(
cnt
)
node
.
read_all
()
node
.
print_status
()
#for pol in list(LOC_POLS.keys()):
# polletje = c_pol(pol
)
# polletje
.print_status()
#
for cnt in range(2):
#
node = c_node(cnt)
#
node.read_all()
#
node.print_status()
unb
=
c_unb2c
unb
.
read_all
(
)
unb
.
print_status
()
\ No newline at end of file
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