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
d2ee8f8b
Commit
d2ee8f8b
authored
4 years ago
by
Gijs Schoonderbeek
Browse files
Options
Downloads
Patches
Plain Diff
rb_unb2c.py third round in classification tested on the HW
parent
a35a4729
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
+15
-15
15 additions, 15 deletions
rd_unb2c.py
with
15 additions
and
15 deletions
rd_unb2c.py
+
15
−
15
View file @
d2ee8f8b
...
...
@@ -16,16 +16,16 @@ from UniBoard2_I2C import *
I2CBUSNR
=
3
class
c_unb2c
:
def
__init
(
self
):
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
.
pols
.
append
(
c_pol
(
pol
,
type
=
"
central
"
))
self
.
dev_i2c_eeprom
=
I2C
(
EEPROM
)
self
.
dev_i2c_eeprom
=
I2CBUSNR
self
.
dev_i2c_eeprom
.
bus
=
I2CBUSNR
def
write_eeprom
(
self
,
data
=
0x01
):
ret_ack
,
ret_value
=
self
.
dev_i2c_eeprom
.
read_bytes
(
0
)
...
...
@@ -34,23 +34,22 @@ class c_unb2c:
else
:
self
.
dev_i2c_eeprom
.
write_bytes
(
0x00
,
data
)
def
read_eeprom
(
self
,
data
):
def
read_eeprom
(
self
):
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
)
ret_ack
,
ret_value
=
self
.
dev_i2c_eeprom
.
read_bytes
(
0x00
,
1
)
return
ret_value
def
wr_rd_eeprom
(
self
):
self
.
write_eeprom
(
0x12
)
def
wr_rd_eeprom
(
self
,
value
=
0x34
):
self
.
write_eeprom
(
value
)
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
):
def
front_led
(
self
,
collor
):
main_switch
=
I2C
(
MAIN_I2C_SWITCH
)
main_switch
.
bus
=
I2CBUSNR
ret_ack
=
main_switch
.
write_bytes
(
0x20
,
0x20
)
#select LED
...
...
@@ -68,7 +67,7 @@ class c_unb2c:
def
read_all
(
self
):
for
node
in
self
.
nodes
:
node
.
read_all
()
for
pol
in
self
.
node
s
:
for
pol
in
self
.
pol
s
:
pol
.
read_all
()
def
print_status
(
self
):
...
...
@@ -77,7 +76,7 @@ class c_unb2c:
self
.
front_led
(
LED_COLORS
[
color
])
for
node
in
self
.
nodes
:
node
.
print_status
()
for
pol
in
self
.
node
s
:
for
pol
in
self
.
pol
s
:
pol
.
print_status
()
self
.
wr_rd_eeprom
()
...
...
@@ -149,7 +148,6 @@ class c_qsfp:
def
read_temp
(
self
):
self
.
select_qsfp
()
print
(
"
read QSFP
"
)
ret_ack
,
raw_ret
=
self
.
qsfp_cage
.
read_bytes
(
QSFP_TEMP
,
2
)
if
(
ret_ack
<
1
)
|
(
raw_ret
[:
2
]
==
'
ff
'
):
# stri = "No QSFP found in port {0}".format(self.port)
...
...
@@ -240,6 +238,8 @@ class c_pol:
if
type
==
"
node
"
:
self
.
set_i2c_switch
()
self
.
pol_dev
=
I2C
(
LOC_POLS
[
self
.
name
])
else
:
self
.
pol_dev
=
I2C
(
CTR_POLS
[
self
.
name
])
self
.
pol_dev
.
bus
=
I2CBUSNR
sleep
(
0.1
)
ret_ack
,
ret_value
=
self
.
pol_dev
.
read_bytes
(
0
)
...
...
@@ -498,6 +498,6 @@ if 0:
# node = c_node(cnt)
# node.read_all()
# node.print_status()
unb
=
c_unb2c
unb
=
c_unb2c
()
unb
.
read_all
()
unb
.
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